Your browser lacks required capabilities. Please upgrade it or switch to another to continue.
Loading…
<strong>Space Snacks</strong>
<strong>by Janos Biro</strong>
A minimalist sci-fi RPG based on Space Reavers.
----
!!<<link "[New]" "Generate">><</link>>
!!<<link "[Saves]">><<run UI.saves()>><</link>>
!!<<link "[Credits]">>\
<<dialog 'Credits'>>\
This game was coded by Janos Biro during may 2020 using Twine 2.3.8 / SugarCube 2.31.1.
It uses the Dialog, CSS and Playtime custom macros by [[Chapel|https://twinelab.net/custom-macros-for-sugarcube-2/#/]].
It was based on [[Space Reavers|https://gnarledmonster.itch.io/space-reavers]], by Alex Damaceno.
[[Follow Janos Biro|https://janosbiro.itch.io]]
[[Follow Alex Damaceno|https://gnarledmonster.itch.io/]]
<</dialog>>\
<</link>><<run UIBar.destroy()>>
<<set $class to either("human", "alien", "robot", "freak")>>\
<<set $tool_list to
["chemical analyzer","drilling machine","stealth module","force field generator","geolocator","fusion recycler", "personal scanner","hologram projector","hydraulic opener","laser cutter","magnetic sensors","multi-tools","plasma rivet gun","omni-torch","exohammer","hacking kit","hand computer"]>>\
<<set $fashion_head to
["cowboy hat","colorful hair","mysterious hood","mohican","gas mask","eccentric make-up","augmenting monocle","cool helmet","exotic earrings","piercings","mustache","long beard","ponytail","mullet","long braids","face bandages","shaved head","sunglasses","metal headband", "eyepatch"]>>\
<<set $fashion_body to
["engineer jumpsuit","tattoos","tight corset","padded waistcoat","multipurpose belt","trenchcoat","shining necklace","military uniform","jackboots","blinking sneakers","prosthetic leg","knee pads","fishnets","armored spacesuit","body straps","fiber tunic"]>>\
<<set $feat_head to
["multiple eyes","antlers","horns","exposed fangs","multi-colored eyes","visible brain","hard beak","pointy ears","giant mouth","long neck","huge eyes","snout"]>>\
<<set $feat_body to
["scaly wings","colorful skin","tentacles","four arms","sharp claws","long tail","long limbs","elastic body","hard scales","thick fur","huge body"]>>\
<<set $misfortune to ["bankrupt","incriminated","replaced","persecuted","discriminated","indebted","low-born","enslaved","cloned","sabotaged","blackmailed","excommunicated","addicted","disinherited","mutilated","cheated","robbed","exiled","kidnapped","discredited","fired"]>>\
<<set $utility to
["fix machines","control engines","create apps","pilot vehicles","exterminate pests","track targets","tame animals","make drinks","decipher codes","sew clothes","paint walls","record events","manage traffic","imitate people","deliver snacks","recognize patterns","clean houses","cook food","build structures","translate documents","babysit children","recycle scraps","play videogames","perform surgery","play music","calculate probability","investigate crimes","play sports","perform diagnosis", "write books", "review movies"]>>\
<<set $obsession to ["theater","literature","history","music","painting","sculpting","anthropology","biology","botany","archaeology","mysticism","psychology","firearms","puzzles","chemistry","fashion","cinema","wrestling","religion","politics","architecture","journalism","gambling","philosophy","cooking","celebrities","spacecrafts","laws"]>>\
<<set $kind to ["fried","organic","dried","raw","cooked","spicy","wild","acid","sweet","rotten","bitter", "synthetic", "toasted", "boiled"]>>\
<<set $food to ["strawberry","grape","banana","apple","orange","lemon","avocado","pineapple","papaya","coconut","beet","potato","carrot","onion","garlic","tomato","pumpkin","chocolate","fish","chicken","meat","cheese","egg"]>>\
<<set $form to ["ice-cream","pie","cake","pizza","cookie","chips","sandwich","wrap","pastry"]>>\
<<set $human_name to
["Ashley","Avery","Blake","Brett","Chris","Connor","Gayle","Glenn","Harley","Hunter","Izzy","Max","Morgan","Nicky","Pat","Phil","Dorian","Darryl","Easton","Elliot","Finley","Frank","Jackie","Jerry","Kelly","Kimberly","Lesly","Ricky","Robin","Steph","Theo","Val","Willy","Aamew","Aarled","Alben","Arrymo","Atharl","Carlie","Clouise","Eustin","Goroy","Hony","Jamy","Jase","Jeffry","Johnny","Jose","Keve","Mase","Matthy","Raige","Randy","Rise","Samy","Tine","Victoph","Vidy"]>>\
<<set $human_surname to
["Homart", "Hardson", "Soner", "Keray", "Ramart", "Russon", "Barnes", "Coxand", "Brighte", "Breenes", "Whezal", "Smire", "Wardson", "Brichy", "Johnson", "Pete", "Jenking", "Walker", "Rodray", "Cotte", "Mitchy", "Morgers", "Reson", "Moora", "Collee", "Rice", "Rownels", "Coopet", "Mithy"]>>\
<<set $alien_name to
["Drak","Darg","Flag","Bark","Jaarg","Vaarg","Jerk","Veerg","Berk","Zerk","Flek","Brek","Vorg","Mork","Zoorg","Gloog","Dork","Flok","Brag","Jark","Faarg","Zaarg","Rark","Mark","Merk","Dreeg","Breeg","Vrek","Drek","Berk","Boorg","Fork","Doorg","Foorg","Gork","Brok"]>>\
<<set $alien_surname to
["Ajil","Anid","Anthan","Traithi","Bane","Kifa","Bani","B'Bari","Byorma","H'Icron","Ch'Rathi","C'Trani","Deani","F'Gliboe","H'Shooke","I'Byni","I'Gnasu","J'Taga","Kale","Vorcia","Vonga","Keno","K'Herle","Loni","Mani","Cilpha","M'Hiloo","Morthra","M'Teda","O'Dongi","Hani","V'Morle","Graka","Tanndi","T'Krypta","Trahva","Vadi","Veni","Wooki","Zabri","Ch'Coloo","Z'Nacia","Z'Sheri"]>>\
<<set $robot_label to
["Alpha","Beta","Gamma","Delta","Epsilon","Zeta","Theta","Kappa","Lambda","Pi","Sigma","Omega","X","T","D","R","C","P","S","B","H","V"]>>\
<<set $planet to ["Zi Xiu IV", "Vespae IV", "Jordani V", "Serpentis IV", "Shatabhisha II", "Antini IV", "Vespae III", "Achelois VI", "Adin II", "Aethalides", "Aman Nini's Stand", "Bani I'Qwoke", "Ceani II", "Chitemia", "Clio VII", "Coithea", "Colvovis", "Coly II", "Cypso 7WWL", "Dori Kily's World", "Elysium", "Ferra", "Gilgamesh", "Grippe Q33F", "Harmonia", "Hinzides", "Huang-Di", "K'Feri", "Krigi", "Meskhent III", "Muuha VI", "New Babylon", "New Madrid", "New Phaeton", "New Russia", "New Venus", "Nigitov", "Phoraturn", "Roni's Landing", "S'Roni", "Svyatogor Prime", "Th'Byni", "Thykra", "Ticia", "Tl'Tazo's Stand", "V'Horta", "Vicrilia", "Zabra III", "Zacha Tracki", "Zoucury"]>>\<<set $modstr to 0>><<set $moddex to 0>><<set $modwit to 0>>\
<<if $arena is 1>><<set $arena to 0>><</if>>\
<<if $giant is 1>><<set $giant to 0>><</if>><<if $rival is 1>><<set $rival to 0>><</if>><<if $clone is 1>><<set $clone to 0>><</if>>\
<<if $enemy is 1>><<set $enemy to 0>><</if>><<if $master is 1>><<set $master to 0>><</if>>\
<span id="stats"><<include "Stats">></span>
You are trapped on $loc and your ship needs repairs.
<span id="op"></span>
<<link "[Look]">>\
<<replace "#op">>You are at your ship. Explore this planet to find resources.<</replace>>\
<<if $class is "robot">><<append "#op">> You can repair yourself or change your mod using 1 battery.<</append>><</if>>\
<</link>> \
<<link "[Ship]">>\
<<replace "#op2">>
Ship status: <<= $ship+"%">> functional.
<<if $ship lt 100>>\
For the next repair you will need the <<= $part>> and 2 batteries.
<<link "[Try to repair]" >>\
<<roll $wit $modwit>>\
<<if $tool.includes($part)>>\
<<if $batt gte 2>><<set $dif to 10+Math.trunc($ship / 10)-$level>>\
<<if $res gte $dif>>\
<<replace "#op">>The repair was successful.<</replace>><<set $batt -= 2>><<set $ship += random(5,20)>><<set $xp += 500>>\
<<if $ship gte 100>><<set $ship to 100>>\
<<append "#op">> You did it! The ship is fully functional.<</append>><<set $xp += 500>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<<else>>
<<append "#op">> You are one step closer to get out of this planet. The ship is <<= $ship+"%">> functional.<</append>>\
<<set $part to $tool_list.random()>>\
<</if>>\
<<else>><<replace "#op">>You failed to repair the ship. Try again at a higher level.<</replace>><<set $batt -= 2>>\
<</if>>\
<<else>><<replace "#op">>You need 2 batteries to attempt the repair. Find them out there.<</replace>>\
<</if>>\
<<else>><<replace "#op">>You need the $part to repair the ship. Get it first.<</replace>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<</link>> \
<<else>>\
<<link "[Launch]">>\
<<dialog 'The End'>>\
Finally, you get out of this planet and set for one where you hope to find more of your favorite snack.
You have eaten $numsnacks snacks.
You have beaten $numbeats enemies.
You have $storage.length tools in storage.
You have found your favorite snack $favfound times.
You played for <<playtime>>.
Congratulations and thank you for playing.
<<link "[Menu]">>\
<<run Engine.restart()>>\
<</link>> \
<</dialog>>\
<</link>> \
<</if>>\
<</replace>>\
<</link>> \
<<link "[Storage]">>\
<<storage>>\
<</link>> \
<<link "[Snacks]">>\
<<if $snacks gt 0>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</link>> \
<<if $class is "robot">>\
<<link "[Repair]">>\
<<if $batt gt 0>>\
<<set $batt-->><<set $hp += random(1,5)>><<if $hp gt $maxhp>><<set $hp to $maxhp>><</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op">>You use 1 battery to repair yourself.<</replace>>\
<<else>><<replace "#op">>You need 1 battery to repair yourself.<</replace>>\
<</if>>\
<</link>> \
<<link "[Mod]">>\
<<if $batt gt 0>><<set $batt-->>\
<<replace "#op2">>
Choose a mod:
<<link "[STR mod]">><<replace "#op">>You are now on STR mod.<</replace>>\
<<set $modstr to 2>><<set $moddex to -1>><<set $modwit to -1>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[DEX mod]">><<replace "#op">>You are now on DEX mod.<</replace>>\
<<set $modstr to -1>><<set $moddex to 2>><<set $modwit to -1>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[WIT mod]">><<replace "#op">>You are now on WIT mod.<</replace>>\
<<set $modstr to -1>><<set $moddex to -1>><<set $modwit to 2>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[No mod]">><<replace "#op">>You turn your mod off.<</replace>>\
<<set $modstr to 0>><<set $moddex to 0>><<set $modwit to 0>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<</replace>>\
<<else>><<replace "#op">>You need 1 battery to change mod.<</replace>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<</if>>\
<<link "[Explore]">><<set $enc to 0>><<explore>>\
<</link>> \
<<link "[Level Up]">>\
<<if $xp gte $next>>\
<<set $level += 1>><<set $next to ($xptolvl*$level)>>\
<<replace "#op">><<= "You are now level "+$level+". ">><</replace>>\
<<replace "#op2">>
<<switch $class>>\
<<case "human">>\
<<set $hp += 2>><<set $maxhp += 2>><<append "#op">><<= "+2 HP. ">><</append>>\
<<set $rndability to either("STR", "DEX", "WIT")>>\
<<if $rndability is "STR">><<set $str++>><<append "#op">><<= "+1 STR. ">><</append>><</if>>\
<<if $rndability is "DEX">><<set $dex++>><<append "#op">><<= "+1 DEX. ">><</append>><</if>>\
<<if $rndability is "WIT">><<set $wit++>><<append "#op">><<= "+1 WIT. ">><</append>><</if>>\
<<set $points++>>\
<<case "alien">>\
<<set $hp += 3>><<set $maxhp += 3>><<append "#op">><<= "+3 HP. ">><</append>>\
<<for _n to 0; _n lt 3; _n++>>\
<<set $rndability to either("STR", "DEX", "WIT")>>\
<<if $rndability is "STR">><<set $str++>><<append "#op">><<= "+1 STR. ">><</append>><</if>>\
<<if $rndability is "DEX">><<set $dex++>><<append "#op">><<= "+1 DEX. ">><</append>><</if>>\
<<if $rndability is "WIT">><<set $wit++>><<append "#op">><<= "+1 WIT. ">><</append>><</if>>\
<</for>>\
<<case "robot">>\
<<set $hp += 1>><<set $maxhp += 1>><<append "#op">><<= "+1 HP. ">><</append>>\
<<set $points++>>\
<<case "freak">>\
<<if $level%2 == 0>>\
<<set $points++>><<set $hp += 2>><<set $maxhp += 2>><<append "#op">><<= "+2 HP. ">><</append>>\
<<else>><<set $hp += 1>><<set $maxhp += 1>><<append "#op">><<= "+1 HP. ">><</append>>\
<</if>>\
<<set $rndability to either("STR", "DEX", "WIT")>>\
<<if $rndability is "STR">><<set $str++>><<append "#op">><<= "+1 STR. ">><</append>><</if>>\
<<if $rndability is "DEX">><<set $dex++>><<append "#op">><<= "+1 DEX. ">><</append>><</if>>\
<<if $rndability is "WIT">><<set $wit++>><<append "#op">><<= "+1 WIT. ">><</append>><</if>>\
<</switch>>\
<</replace>>\
<<else>>\
<<replace "#op">><<= "You need more "+($next-$xp)+" xp to level up.">><</replace>>\
<</if>>\
<<if $points gt 0>>\
<<replace "#op2">>
Points: <<= $points>>
<<raise_ability>><</replace>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Saves]">>\
<<run UI.saves()>>\
<</link>> \
<<link "[Menu]">>\
<<dialog 'Check'>>\
Are you sure you want to go back to the main menu? Your unsaved progress will be lost.
<<link "[Confirm]">>\
<<run Engine.restart()>>\
<</link>> \
<</dialog>>\
<</link>> \
<span id="op2"></span><<widget "explore">>\
<<if $enc is 0>><<set $enc to random(1,20)>><</if>>\
<<set $shield to 0>><<set $holo to 0>><<set $burn to 0>><<set $stun to 0>>\
<<switch $enc>>\
<<case 1>><<goto "Snack Machine">>\
<<case 2>><<goto "Snack Store">>\
<<case 3>><<goto "Scrapyard">>\
<<case 4>><<goto "NPC">>\
<<case 5>><<goto "Tool Store">>\
<<case 6>><<goto "Battery Machine">>\
<<case 7>><<goto "Shipyard">>\
<<case 8>><<goto "Dangerous Zone">>\
<<case 9>><<goto "Arena">>\
<<case 10>><<goto "Robot Boxing">>\
<<case 11>><<goto "Jet Pack Racing">>\
<<case 12>><<goto "Cantina">>\
<<case 13>><<goto "Lab">>\
<<case 14>><<goto "Racetrack">>\
<<case 15>><<goto "Body Shop">>\
<<case 16>><<goto "Ambush">>\
<<case 17>><<goto "Locked Storage">>\
<<case 18>><<goto "Workbench">>\
<<case 19>><<goto "Rogue Nanobot">>\
<<case 20>><<goto "Broken Robot">>\
<</switch>>\
<</widget>>
<<widget "raise_ability">>\
<<link "[Raise STR]">>\
<<set $points-->><<set $str++>><<append "#op">><<= "+1 STR. ">><</append>>\
<<replace "#op2">>
Points: <<= $points>>
<<raise_ability>><</replace>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<if $points is 0>><<replace "#op2">><</replace>><</if>>\
<</link>> \
<<link"[Raise DEX]">>\
<<set $points-->><<set $dex++>><<append "#op">><<= "+1 DEX. ">><</append>>\
<<replace "#op2">>
Points: <<= $points>>
<<raise_ability>><</replace>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<if $points is 0>><<replace "#op2">><</replace>><</if>>\
<</link>> \
<<link "[Raise WIT]">>\
<<set $points-->><<set $wit++>><<append "#op">><<= "+1 WIT. ">><</append>>\
<<replace "#op2">>
Points: <<= $points>>
<<raise_ability>><</replace>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<if $points is 0>><<replace "#op2">><</replace>><</if>>\
<</link>>\
<</widget>>
<<widget "link_eat">>\
<<link $args[1] >>\
<<if $class is "robot">>\
<<if $bag[$args[0]] is $favsnack>><<set $xp += 500>><<set $feel to "the best feeling ever">>\
<<else>><<set $xp += 50>><<set $feel to "better">>\
<</if>>\
<<else>>\
<<if $proved.includes($bag[$args[0]])>>\
<<for _i to 0; _i lt $proved.length; _i++>><<if $proved[_i] is $bag[$args[0]]>><<set $sn to _i>><<break>><</if>><</for>>\
<<else>>\
<<set $sn to $proved.length>><<run $proved.push($bag[$args[0]])>><<set $snstr[$sn] to 0>><<set $sndex[$sn] to 0>><<set $snwit[$sn] to 0>>\
<<set $d1 to random(1,3)>><<if $class is "alien">><<set $val to either(-2,0,2)>><<else>><<set $val to random(-1,1)>><</if>>\
<<if $d1 is 1>><<set $snstr[$sn] to $val>><</if >><<if $d1 is 2>><<set $sndex[$sn] to $val>><</if >><<if $d1 is 3>><<set $snwit[$sn] to $val>><</if >>\
<</if>>\
<<set $modstr += $snstr[$sn]>><<set $moddex += $sndex[$sn]>><<set $modwit += $snwit[$sn]>><<set $feel to "better">>\
<<if $snstr[$sn] gt 0>><<set $feel to "stronger">><<elseif $snstr[$sn] lt 0>><<set $feel to "weaker">><</if>>\
<<if $sndex[$sn] gt 0>><<set $feel to "quicker">><<elseif $sndex[$sn] lt 0>><<set $feel to "slower">><</if>>\
<<if $snwit[$sn] gt 0>><<set $feel to "smarter">><<elseif $snwit[$sn] lt 0>><<set $feel to "dumber">><</if>>\
<<if $sn is 0>><<set $feel to "the best feeling ever">><</if >>\
<<if $class is "alien">><<set $modstr to Math.clamp($modstr, -4, 4)>><<set $moddex to Math.clamp($moddex, -4, 4)>><<set $modwit to Math.clamp($modwit, -4, 4)>>\
<<else>><<set $modstr to Math.clamp($modstr, -3, 3)>><<set $moddex to Math.clamp($moddex, -3, 3)>><<set $modwit to Math.clamp($modwit, -3, 3)>><</if>>\
<<set $hp += random(1,5)>><<if $hp gt $maxhp>><<set $hp to $maxhp>><</if>>\
<</if>>\
<<replace "#op">><<= "You eat the "+$bag[$args[0]]+" and feel "+$feel+".">><</replace>><<set $snacks-->><<run $bag.deleteAt($args[0])>><<set $numsnacks++>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<</link>> \
<</widget>>
<<widget "link_cantina">>\
<<link $args[1] >>\
<<if $cred gte $price>>\
<<if $class is "robot">>\
<<if $kitchen[$args[0]] is $favsnack>><<set $xp += 500>><<set $feel to "the best feeling ever">>\
<<else>><<set $xp += 50>><<set $feel to "better">>\
<</if>>\
<<else>>\
<<if $proved.includes($kitchen[$args[0]])>>\
<<for _i to 0; _i lt $proved.length; _i++>><<if $proved[_i] is $kitchen[$args[0]]>><<set $sn to _i>><<break>><</if>><</for>>\
<<else>>\
<<set $sn to $proved.length>><<run $proved.push($kitchen[$args[0]])>><<set $snstr[$sn] to 0>><<set $sndex[$sn] to 0>><<set $snwit[$sn] to 0>>\
<<set $d1 to random(1,3)>><<if $class is "alien">><<set $val to either(-2,0,2)>><<else>><<set $val to random(-1,1)>><</if>>\
<<if $d1 is 1>><<set $snstr[$sn] to $val>><</if >><<if $d1 is 2>><<set $sndex[$sn] to $val>><</if >><<if $d1 is 3>><<set $snwit[$sn] to $val>><</if >>\
<</if>>\
<<set $modstr += $snstr[$sn]>><<set $moddex += $sndex[$sn]>><<set $modwit += $snwit[$sn]>><<set $feel to "better">>\
<<if $snstr[$sn] gt 0>><<set $feel to "stronger">><<elseif $snstr[$sn] lt 0>><<set $feel to "weaker">><</if>>\
<<if $sndex[$sn] gt 0>><<set $feel to "quicker">><<elseif $sndex[$sn] lt 0>><<set $feel to "slower">><</if>>\
<<if $snwit[$sn] gt 0>><<set $feel to "smarter">><<elseif $snwit[$sn] lt 0>><<set $feel to "dumber">><</if>>\
<<if $sn is 0>><<set $feel to "the best feeling ever">><</if >>\
<<if $class is "alien">><<set $modstr to Math.clamp($modstr, -4, 4)>><<set $moddex to Math.clamp($moddex, -4, 4)>><<set $modwit to Math.clamp($modwit, -4, 4)>>\
<<else>><<set $modstr to Math.clamp($modstr, -3, 3)>><<set $moddex to Math.clamp($moddex, -3, 3)>><<set $modwit to Math.clamp($modwit, -3, 3)>><</if>>\
<<set $hp += random(1,5)>><<if $hp gt $maxhp>><<set $hp to $maxhp>><</if>>\
<</if>>\
<<replace "#op">><<= "You eat the "+$kitchen[$args[0]]+" and feel "+$feel+".">><</replace>><<set $numsnacks++>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<</link>> \
<</widget>>
<<widget "link_get">>\
<<link $args[1] >>\
<<if $tool.length lt 5>><<replace "#op">><<= "You get the "+$storage[$args[0]]+" from the storage.">><</replace>>\
<<run $tool.push($storage[$args[0]])>><<run $storage.deleteAt($args[0])>><<storage>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<else>><<replace "#op">><<= "You cannot carry more tools with you. Try to store one first.">><</replace>>\
<</if>>\
<</link>> \
<</widget>>
<<widget "link_put">>\
<<link $args[1] >>\
<<if $storage.length lt 10>><<replace "#op">><<= "You place the "+$tool[$args[0]]+" in the storage.">><</replace>>\
<<run $storage.push($tool[$args[0]])>><<run $tool.deleteAt($args[0])>><<storage>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<else>><<replace "#op">><<= "The storage is full.">><</replace>>\
<</if>>\
<</link>> \
<</widget>>
<<widget "storage">>\
<<replace "#op2">>
Your storage compartment contains:
<<for _n to 0; _n lt $storage.length; _n++>>\
<<link_get _n '[$storage[_n]]'>>\
<</for>>
Choose a tool to store:
<<for _n to 0; _n lt $tool.length; _n++>>\
<<link_put _n '[$tool[_n]]'>>\
<</for>>\
<</replace>>\
<</widget>>
<<widget "link_buy">>\
<<link $args[1] >>\
<<if $bag.length lt 10>>\
<<if $cred gte $price>>\
<<set $cred to $cred-$price>><<set $snacks++>><<run $bag.push($machine[$args[0]])>>\
<<replace "#op">><<= "You got the "+$machine[$args[0]]+".">><</replace>>\
<<if $machine[$args[0]] is $favsnack>><<append "#op">><<= " It is your favorite!">><</append>><<set $favfound++>><</if>>\
<<run $machine.deleteAt($args[0])>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<<else>><<replace "#op">>You cannot carry any more snacks.<</replace>>\
<</if>>\
<</link>> \
<</widget>>
<<widget "link_store">>\
<<link $args[1] >>\
<<if $bag.length lt 10>>\
<<if $sale.includes($store[$args[0]])>>\
<<if $cred gte $price2>><<set $snacks++>><<run $bag.push($store[$args[0]])>>\
<<replace "#op">><<= "You got the "+$store[$args[0]]+".">><</replace>>\
<<if $store[$args[0]] is $favsnack>><<append "#op">><<= " It is your favorite!">><</append>><<set $favfound++>><</if>>\
<<set $cred to $cred-$price2>><<run $sale.delete($store[$args[0]])>><<append "#op">><<= " It was on sale.">><</append>>\
<<run $store.deleteAt($args[0])>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<<else>>\
<<if $cred gte $price>><<set $snacks++>><<run $bag.push($store[$args[0]])>>\
<<replace "#op">><<= "You got the "+$store[$args[0]]+".">><</replace>>\
<<if $store[$args[0]] is $favsnack>><<append "#op">><<= " It is your favorite!">><</append>><<set $favfound++>><</if>>\
<<set $cred to $cred-$price>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<</if>>\
<<else>><<replace "#op">>You cannot carry any more snacks.<</replace>>\
<</if>>\
<</link>> \
<</widget>>
<<widget "tool_buy">>\
<<link $args[1] >>\
<<if $tool.length lt 5>>\
<<if $cred gte $price>>
<<set $cred to $cred-$price>><<run $tool.push($tool_store[$args[0]])>>\
<<replace "#op">><<= "You got the "+$tool_store[$args[0]]+".">><</replace>>\
<<if $tool_store[$args[0]] is $part>><<set $xp += 500>><<append "#op">><<= " Just what you needed! (+500xp)">><</append>><</if>>\
<<run $tool_store.deleteAt($args[0])>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<<else>><<replace "#op">>You cannot carry any more tools.<</replace>>\
<</if>>\
<</link>> \
<</widget>>
<<widget "tool_sell">>\
<<link $args[1] >>\
<<set $cred to $cred+$price2>><<run $tool_store.push($tool[$args[0]])>>\
<<replace "#op">><<= "You sold the "+$tool[$args[0]]+".">><</replace>>\
<<run $tool.deleteAt($args[0])>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<</link>> \
<</widget>>
<<widget "zone_sell">>\
<<link $args[1] >>\
<<if $tool_zone.includes($tool[$args[0]])>>\
<<set $cred to $cred+$price>>\
<<replace "#op">><<= "You sold the "+$tool[$args[0]]+".">><</replace>>\
<<run $tool.deleteAt($args[0])>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<<else>><<replace "#op">><<= "We don't need this.">><</replace>>\
<</if>>\
<</link>> \
<</widget>>
<<widget "zone_buy">>\
<<link $args[1] >>\
<<if $tool.length lt 5>>\
<<if $cred gte $price>>
<<set $cred to $cred-$price>><<run $tool.push($tool_zone[$args[0]])>>\
<<replace "#op">><<= "You got the "+$tool_zone[$args[0]]+".">><</replace>>\
<<if $tool_zone[$args[0]] is $part>><<set $xp += 500>><<append "#op">><<= " Just what you needed! (+500xp)">><</append>><</if>>\
<<run $tool_zone.deleteAt($args[0])>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<<else>><<replace "#op">>You cannot carry any more tools.<</replace>>\
<</if>>\
<</link>> \
<</widget>>
<<widget "tool_trade">>\
<<link $args[1] >>\
<<replace "#op">><<= "You trade the "+$tool[$args[0]]+" for the "+$npc_trade+".">><</replace>>\
<<run $tool.deleteAt($args[0])>><<run $tool.push($npc_trade)>><<set $npc_trade to "">>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<</link>> \
<</widget>>
<<widget "tool_dis">>\
<<link $args[1] >>\
<<replace "#op">><<= "You dismantle the "+$tool[$args[0]]+".">><</replace>><<run $tool.deleteAt($args[0])>>\
<<replace "#op2">>
Choose a tool to make:
<<for _n to 0; _n lt $tool_list.length; _n++>><<tool_make _n '[$tool_list[_n]]'>><</for>>\
<</replace>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<</widget>>
<<widget "tool_make">>\
<<link $args[1] >>\
<<roll $wit $modwit>><<set $dif to 10>>\
<<if $res gte $dif>>\
<<run $tool.push($tool_list[$args[0]])>><<replace "#op">><<= "You made the "+$tool_list[$args[0]]+".">><</replace>>\
<<if $tool_list[$args[0]] is $part>><<set $xp += 500>><<append "#op">><<= " Just what you needed! (+500xp)">><</append>><</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<<else>><<replace "#op">>You failed.<</replace>><<replace "#op2">><</replace>>\
<</if>>\
<</link>> \
<</widget>>
<<widget "link_racer">>\
<<link $args[1] >>\
<<set $bet to $args[0]>><<replace "#op">>You are betting on <<= $racer[$args[0]]>>.<</replace>>\
<</link>> \
<</widget>>
<<widget "snack_give">>\
<<link $args[1] >>\
<<set $npc_look to either("happy", "friendly", "relaxed", "thankful")>><<set $npc_hate to "">>\
<<if $bag[$args[0]] is $npc_fav>>\
<<replace "#op">><<= "The "+$npc+" is amazed with your gift. Now it looks "+$npc_look+".">><</replace>><<set $xp += 500>>\
<<if $npc_trade isnot "">><<append "#op">><<= " The "+$npc+" gives the "+$npc_trade+" to you.">><</append>>\
<<run $tool.push($npc_trade)>><<set $npc_trade to "">>\
<<elseif $npc_cred gt 0>><<append "#op">><<= " The "+$npc+" gives you "+$npc_cred+" credits.">><</append>>\
<<set $cred += $npc_cred>><<set $npc_cred to 0>>\
<</if>>\
<<else>>\
<<replace "#op">><<= "The "+$npc+" likes your gift. Now it looks "+$npc_look+".">><</replace>><<set $xp += 100>>\
<</if>>\
<<set $snacks-->><<run $bag.deleteAt($args[0])>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<</link>> \
<</widget>>
<<widget "tool_use">>\
<<link $args[1] >>\
<<if $hp gt 0>>\
<<if $batt gt 0 or $tool[$args[0]] is "fusion recycler">>\
<<switch $tool[$args[0]]>>\
<<case "chemical analyzer">>\
<<if $combat is 0>><<set $batt-->>\
<<for _i to 0; _i lt $bag.length; _i++>>\
<<if $proved.includes($bag[_i])>><<else>>\
<<set $sn to $proved.length>><<run $proved.push($bag[_i])>><<set $snstr[$sn] to 0>><<set $sndex[$sn] to 0>><<set $snwit[$sn] to 0>>\
<<set $d1 to random(1,3)>><<if $class is "alien">><<set $val to either(-2,0,2)>><<else>><<set $val to random(-1,1)>><</if>>\
<<if $d1 is 1>><<set $snstr[$sn] to $val>><</if >><<if $d1 is 2>><<set $sndex[$sn] to $val>><</if >><<if $d1 is 3>><<set $snwit[$sn] to $val>><</if >>\
<</if>>\
<</for>>\
<<dialog 'chemical analyzer'>>\
<<for _i to 0; _i lt $proved.length; _i++>>\
<<if $bag.includes($proved[_i])>><<= $proved[_i] +": ">>\
<<if $snstr[_i] gt 0>><<= "+STR">><<elseif $snstr[_i] lt 0>><<= "-STR">><</if>>\
<<if $sndex[_i] gt 0>><<= "+DEX">><<elseif $sndex[_i] lt 0>><<= "-DEX">><</if>>\
<<if $snwit[_i] gt 0>><<= "+WIT">><<elseif $snwit[_i] lt 0>><<= "-WIT">><</if>>\
<</if>>\
<</for>>\
<</dialog>>\
<<else>><<replace "#op">>You cannot use this tool while in combat.<</replace>>\
<</if>>\
<<case "drilling machine">>\
<<if $combat is 0 and $race is 0>>\
<<if $enc is 11 or $enc is 14>><<set $batt-->>\
<<replace "#op2">>
Choose a racer to sabotage:
<<link '[$racer[0]]' >><<set $racer_dex[0] to 6>><<replace "#op">>You sabotage <<= $racer[0]>>.<</replace>><<replace "#op2">><</replace>><</link>> \
<<link '[$racer[1]]' >><<set $racer_dex[1] to 6>><<replace "#op">>You sabotage <<= $racer[1]>>.<</replace>><<replace "#op2">><</replace>><</link>> \
<<link '[$racer[2]]' >><<set $racer_dex[2] to 6>><<replace "#op">>You sabotage <<= $racer[2]>>.<</replace>><<replace "#op2">><</replace>><</link>> \
<<if $enc is 11>><<link '[$racer[3]]' >><<set $racer_dex[3] to 6>><<replace "#op">>You sabotage <<= $racer[3]>>.<</replace>><<replace "#op2">><</replace>><</link>><</if>>
<</replace>>\
<</if>>\
<<else>><<replace "#op">>No use for that here.<</replace>>\
<</if>>\
<<case "stealth module">>\
<<if $combat is 0>>\
<<if $enc is 2 and $store.length gt 0 and $bag.length lt 10>><<set $batt-->>\
<<set $rndsnack to $store.pluck()>><<set $snacks++>><<run $bag.push($rndsnack)>>\
<<replace "#op">>You use the stealth module to steal a snack from the store.<</replace>><<set $xp += 50>>\
<<if $rndsnack is $favsnack>><<set $xp += 450>><<append "#op">><<= " And it is your favorite! What luck! (+500xp)">><</append>><<set $favfound++>><</if>>\
<<elseif $enc is 5 and $tool_store.length gt 0 and $tool.length lt 5>><<set $batt-->>\
<<set $rndtool to $tool_store.pluck()>><<run $tool.push($rndtool)>>\
<<replace "#op">>You use the stealth module to steal a tool from the store.<</replace>><<set $xp += 250>>\
<<if $rndtool is $part>><<set $xp += 250>><<append "#op">><<= " It is just what you needed! What luck! (+500xp)">><</append>><</if>>\
<<else>><<replace "#op">>No use for that here.<</replace>>\
<</if>>\
<<else>><<set $batt-->><<replace "#op">>You use the stealth module to avoid combat.<</replace>><<set $combat to 0>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<</if>>\
<<case "force field generator">>\
<<if $combat is 0>><<replace "#op">>No use for that here.<</replace>>\
<<else>><<set $batt-->><<replace "#op">>You use the force field generator to temporarily shield you from damage.<</replace>><<set $shield to 2>>\
<</if>>\
<<case "geolocator">>\
<<if $combat is 0>><<set $batt-->>\
<<dialog 'geolocator'>>\
Choose a location to go:
<<link '[Snack Store]'>><<set $enc to 2>><<explore>><<run Dialog.close()>><</link>> \
<<link '[Scrapyard]'>><<set $enc to 3>><<explore>><<run Dialog.close()>><</link>> \
<<link '[Tool Store]'>><<set $enc to 5>><<explore>><<run Dialog.close()>><</link>> \
<<link '[Shipyard]'>><<set $enc to 7>><<explore>><<run Dialog.close()>><</link>> \
<<link '[Arena]'>><<set $enc to 9>><<explore>><<run Dialog.close()>><</link>> \
<<link '[Robot Boxing]'>><<set $enc to 10>><<explore>><<run Dialog.close()>><</link>> \
<<link '[Jet Pack Racing]'>><<set $enc to 11>><<explore>><<run Dialog.close()>><</link>> \
<<link '[Cyberdrone Racetrack]'>><<set $enc to 14>><<explore>><<run Dialog.close()>><</link>> \
<<link '[Cantina]'>><<set $enc to 12>><<explore>><<run Dialog.close()>><</link>> \
<<link '[Alien Lab]'>><<set $enc to 13>><<explore>><<run Dialog.close()>><</link>> \
<<link '[Body Shop]'>><<set $enc to 15>><<explore>><<run Dialog.close()>><</link>> \
<<link '[Workbench]'>><<set $enc to 18>><<explore>><<run Dialog.close()>><</link>> \
<</dialog>>\
<<else>><<replace "#op">>You cannot use this tool while in combat.<</replace>>\
<</if>>\
<<case "fusion recycler">>\
<<if $bag.length is 0>><<replace "#op">>You have no snacks.<</replace>><<else>>\
<<if $combat is 0>>\
<<replace "#op2">>
Choose a snack to fuel the recycler:
<<for _n to 0; _n lt $bag.length; _n++>><<link_recycle _n '[$bag[_n]]'>><</for>>
<</replace>>\
<<else>><<replace "#op">>You cannot use this tool while in combat.<</replace>>\
<</if>>\
<</if>>\
<<case "personal scanner">>\
<<if $combat is 1 or $enc is 4>><<set $batt-->>\
<<dialog 'personal scanner'>>\
<<= $npc.toUpperFirst()>>
STR: $npc_str
DEX: $npc_dex
WIT: $npc_wit
HP: $npc_hp
<</dialog>>\
<<else>><<replace "#op">>No use for that here.<</replace>>\
<</if>>\
<<case "hologram projector">>\
<<if $combat is 0>><<replace "#op">>No use for that here.<</replace>>\
<<else>><<set $batt-->><<replace "#op">>You use the hologram projector to temporarily confuse the $npc.<</replace>><<set $holo to 2>>\
<</if>>\
<<case "hydraulic opener">>\
<<if $combat is 0>>\
<<if $enc is 1 and $machine.length gt 0 and $bag.length lt 10>><<set $batt-->>\
<<set $rndsnack to $machine.pluck()>><<set $snacks++>><<run $bag.push($rndsnack)>>\
<<replace "#op">>You use the hydraulic opener to steal a snack from the machine.<</replace>><<set $xp += 50>>\
<<if $rndsnack is $favsnack>><<set $xp += 450>><<append "#op">><<= " And it is your favorite! What luck! (+500xp)">><</append>><<set $favfound++>><</if>>\
<<elseif $enc is 6 and $batt_machine.length gte 3>><<set $batt-->>\
<<set $batt += 3>><<replace "#op">>You use the hydraulic opener to steal 3 batteries from the machine.<</replace>><<set $xp += 50>>\
<<else>><<replace "#op">>No use for that here.<</replace>>\
<</if>>\
<<else>><<replace "#op">>You cannot use this tool while in combat.<</replace>>\
<</if>>\
<<case "laser cutter">>\
<<if $combat is 0>><<replace "#op">>No use for that here.<</replace>>\
<<else>><<set $batt-->><<replace "#op">>You use the laser cutter to damage and cripple the <<= $npc>>.<</replace>>\
<<roll $dex $moddex>><<set $dam to $res-$npc_dex>><<set $dam to $dam.clamp(1, 5)>>\
<<set $npc_hp to $npc_hp-$dam>><<set $npc_str-->><<replace "#c_op">><<= "You caused "+$dam+" damage and -1 STR.">><</replace>>\
<<if $npc_hp lt 1>><<append "#c_op">><<= " It is down (+"+$npc_xp+"xp).">><</append>><<set $xp += $npc_xp>><<set $combat to 0>><<reward>>\
<<replace "#c_op2">><</replace>><</if>>\
<</if>>\
<<case "magnetic sensors">>\
<<if $combat is 0>>\
<<if $enc is 17 and $opened is 0>><<set $batt-->>\
<<set $tries++>><<replace "#op">>You use the magnetic sensors to get 1 extra try.<</replace>><<replace "#op2">>
Tries left: $tries<</replace>>\
<<else>><<replace "#op">>No use for that here.<</replace>>\
<</if>>\
<<else>><<replace "#op">>You cannot use this tool while in combat.<</replace>>\
<</if>>\
<<case "multi-tools">>\
<<if $class is "robot">>\
<<if $combat is 0>><<set $batt-->><<set $hp += random(1,5)>><<if $hp gt $maxhp>><<set $hp to $maxhp>><</if>>\
<<replace "#op">>You use the multi-tools to repair yourself.<</replace>>\
<<else>><<replace "#op">>You cannot use this tool while in combat.<</replace>>\
<</if>>\
<<else>><<replace "#op">>No use for that here.<</replace>>\
<</if>>\
<<case "plasma rivet gun">>\
<<if $combat is 0>><<replace "#op">>No use for that here.<</replace>>\
<<else>><<set $batt-->><<replace "#op">>You use the plasma rivet gun to damage the <<= $npc>>.<</replace>>\
<<roll $dex $moddex>><<set $dam to $res-$npc_dex>><<set $dam to $dam.clamp(2, 10)>>\
<<set $npc_hp to $npc_hp-$dam>><<replace "#c_op">><<= "You caused "+$dam+" damage.">><</replace>>\
<<if $npc_hp lt 1>><<append "#c_op">><<= " It is down (+"+$npc_xp+"xp).">><</append>><<set $xp += $npc_xp>><<set $combat to 0>><<reward>>\
<<replace "#c_op2">><</replace>><</if>>\
<</if>>\
<<case "omni-torch">>\
<<if $combat is 0>><<replace "#op">>No use for that here.<</replace>>\
<<else>><<set $batt-->><<replace "#op">>You use the omni-torch to incinerate the <<= $npc>>.<</replace>>\
<<roll $dex $moddex>><<set $dam to $res-$npc_dex>><<set $dam to $dam.clamp(1, 5)>><<set $burn to 2>>\
<<set $npc_hp to $npc_hp-$dam>><<replace "#c_op">><<= "You caused "+$dam+" damage and the "+$npc+" is now burning.">><</replace>>\
<<if $npc_hp lt 1>><<append "#c_op">><<= " It is down (+"+$npc_xp+"xp).">><</append>><<set $xp += $npc_xp>><<set $combat to 0>><<reward>>\
<<replace "#c_op2">><</replace>><</if>>\
<</if>>\
<<case "exohammer">>\
<<if $combat is 0>><<replace "#op">>No use for that here.<</replace>>\
<<else>><<set $batt-->><<replace "#op">>You use the exohammer to damage and stun the <<= $npc>>.<</replace>>\
<<roll $str $modstr>><<set $dam to $res-$npc_dex>><<set $dam to $dam.clamp(3, 12)>><<set $stun to 1>>\
<<set $npc_hp to $npc_hp-$dam>><<replace "#c_op">><<= "You caused "+$dam+" damage and the "+$npc+" is stunned.">><</replace>>\
<<if $npc_hp lt 1>><<append "#c_op">><<= " It is down (+"+$npc_xp+"xp).">><</append>><<set $xp += $npc_xp>><<set $combat to 0>><<reward>>\
<<replace "#c_op2">><</replace>><</if>>\
<</if>>\
<<case "hacking kit">>\
<<if $combat is 1 and $npc_class is "robot">><<set $batt-->>\
<<roll $wit $modwit>><<set $dif to $npc_wit>>\
<<if $res gt $dif>><<replace "#op">>You hack the $npc and it is now stunned.<</replace>><<set $stun to 1>>\
<<else>><<replace "#op">>You failed to hack the $npc.<</replace>>\
<</if>>\
<<elseif $enc is 10 and $fight is 0>><<set $batt-->>\
<<replace "#op2">>
Choose a fighter to sabotage:
<<link '[$fighter1]'>><<set $fighter1_str to 10>><<replace "#op">>You sabotage <<= $fighter1>>.<</replace>><<replace "#op2">><</replace>><</link>> \
<<link '[$fighter2]'>><<set $fighter2_str to 10>><<replace "#op">>You sabotage <<= $fighter2>>.<</replace>><<replace "#op2">><</replace>><</link>>
<</replace>>\
<<else>><<replace "#op">>No use for that here.<</replace>>\
<</if>>\
<<case "hand computer">>\
<<if $combat is 0>><<set $batt-->>\
<<dialog 'hand computer'>>\
Your personal assistant says:
<<if $ship is 100>>Your ship is ready to launch.<<else>>You need the $part to repair the ship.<</if>>
You have eaten $numsnacks snacks.
You have beaten $numbeats enemies.
You have $storage.length tools in storage.
You have found your favorite snack $favfound times.
<</dialog>>\
<<else>><<replace "#op">>No use for that here.<</replace>>\
<</if>>\
<</switch>>\
<<else>><<replace "#op">>You have no batteries.<</replace>>\
<</if>>\
<<else>><<replace "#op">>You cannot do this now.<</replace>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<</widget>>
<<widget "link_recycle">>\
<<link $args[1] >>\
<<replace "#op">><<= "You lost the "+$bag[$args[0]]+" and got 1 battery.">><</replace>>\
<<run $bag.deleteAt($args[0])>><<set $batt++>><<set $snacks-->>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">><</replace>>\
<</link>> \
<</widget>>
<<widget "roll">>\
<<set $test to $args[0]>><<set $mod to $args[1]>>\
<<set $d1 to random(1, $test)>><<set $d2 to random(1, 10)>>\
<<set $res to $d1+$d2+$mod>>\
<</widget>>
<<widget "reward">>\
<<set $numbeats++>>
<<if $giant is 1>><<set $giant to 2>><<set $rndtool to $tool_list.random()>>\
<<if $tool.length lt 5>>\
<<replace "#op">><<= "You found the "+$rndtool+" at the lair of the "+$npc+".">><</replace>><<run $tool.push($rndtool)>>\
<<else>><<replace "#op">><<= "You found 1000 credits at the lair of the "+$npc+".">><</replace>><<set $cred += 1000>>\
<</if>>\
<</if>>\
<<if $arena is 1>><<set $arena to 0>><<set $arena_level++>>\
<<replace "#op">><<= "You get "+$prize+" credits for winning.">><<set $cred += $prize>><</replace>>\
<</if>>\
<<if $enc is 16>>\
<<replace "#op">>You loot: $npc_cred credits<</replace>>\
<<if $npc_batt is 1>><<append "#op">>, 1 battery<</append>><<elseif $npc_batt gt 1>><<append "#op">>, $npc_batt batteries<</append>><</if>>\
<<if $bag.length lte 10 - $npc_snack>>\
<<if $npc_snack is 1>><<append "#op">>, 1 snack<</append>><<elseif $npc_snack gt 1>><<append "#op">>, $npc_snack snacks<</append>><</if>>\
<<for _n to 0; _n lt $npc_snack; _n++>><<set $rndsnack to $kind.random() + " " + $food.random() + " " + $form.random()>><<run $bag.push($rndsnack)>>\
<<if $rndsnack is $favsnack>><<set $xp += 500>><<append "#op">><<= " Your favorite snack! What luck! (+500xp)">><</append>><<set $favfound++>><</if>>\
<</for>>\
<</if>>\
<<append "#op">>.<</append>><<set $cred += $npc_cred>><<set $batt += $npc_batt>><<set $snacks += $npc_snack>>\
<</if>>\
<<if $rival is 1>><<set $rival to 2>><<set $rndtool to $tool_list.random()>>\
<<if $tool.length lt 5>>\
<<replace "#op">><<= "You found the "+$rndtool+" with your rival.">><</replace>><<run $tool.push($rndtool)>>\
<<else>><<replace "#op">><<= "You found 1000 credits with your rival.">><</replace>><<set $cred += 1000>>\
<</if>>\
<</if>>\
<<if $clone is 1>><<set $clone to 2>><<set $rndtool to $tool_list.random()>>\
<<if $tool.length lt 5>>\
<<replace "#op">><<= "You found the "+$rndtool+" with your clone.">><</replace>><<run $tool.push($rndtool)>>\
<<else>><<replace "#op">><<= "You found 1000 credits with your clone.">><</replace>><<set $cred += 1000>>\
<</if>>\
<</if>>\
<<if $enemy is 1>><<set $enemy to 2>><<set $rndtool to $tool_list.random()>>\
<<if $tool.length lt 5>>\
<<replace "#op">><<= "You found the "+$rndtool+" with your enemy.">><</replace>><<run $tool.push($rndtool)>>\
<<else>><<replace "#op">><<= "You found 1000 credits with your enemy.">><</replace>><<set $cred += 1000>>\
<</if>>\
<</if>>\
<<if $master is 1>><<set $master to 2>><<set $rndtool to $tool_list.random()>>\
<<if $tool.length lt 5>>\
<<replace "#op">><<= "You found the "+$rndtool+" with your master.">><</replace>><<run $tool.push($rndtool)>>\
<<else>><<replace "#op">><<= "You found 1000 credits with your master.">><</replace>><<set $cred += 1000>>\
<</if>>\
<</if>>\
<</widget>>
<<widget "npc_att">>\
<<if $holo gt 0>><<set $holo-->>\
<<append "#c_op">> It hits the hologram.<</append>><<if $holo is 0>><<append "#c_op">> The hologram fades away.<</append>><</if>><<else>>\
<<if $shield gt 0>><<set $shield-->>\
<<append "#c_op">> Your force field protects you.<</append>><<if $shield is 0>><<append "#c_op">> The force field fades away.<</append>><</if>><<else>>\
<<roll $npc_str 0>><<set $dam to $res-($str+$modstr)>><<set $dam to Math.clamp($dam, 1, 10)>>\
<<set $hp to $hp-$dam>><<append "#c_op">> You lost $dam hp.<</append>>\
<<if $hp lt 1>><<append "#c_op">> You are down.<</append>>\
<<replace "#c_op2">><<link "[Wake up]" "Regeneration Booth">><<set $combat to 0>><</link>><</replace>>\
<</if>>\
<</if>>\
<</if>>\
<</widget>>
<<widget "combat">>\
<<roll $npc_dex 0>><<set $res to $res1>><<roll $dex $moddex>><<set $res to $res2>><<if $res1 gt $res2>><<npc_att>><</if>>\
<<if $hp gt 0>>\
<<replace "#c_op2">>\
<<link "[Attack]">>\
<<roll $str $modstr>><<set $dam to $res-$npc_str>><<set $dam to $dam.clamp(1, 10)>><<if $burn gt 0>><<set $dam++>><</if>>\
<<set $npc_hp to $npc_hp-$dam>><<replace "#c_op">><<= "You caused "+$dam+" damage to the "+$npc+".">><</replace>>\
<<if $burn gt 0>><<set $burn-->><<append "#c_op">><<= " It is burning!">><</append>><</if>>\
<<if $npc_hp lt 1>><<append "#c_op">><<= " It is down (+"+$npc_xp+"xp).">><</append>><<set $xp += $npc_xp>><<set $combat to 0>><<reward>>\
<<replace "#c_op2">><</replace>>\
<<else>>\
<<if $stun gt 0>><<set $stun-->><<append "#c_op">> The $npc is stunned.<</append>><<else>><<append "#c_op">> The $npc attacks you.<</append>><<npc_att>><</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Run]">>\
<<roll $dex $moddex>><<set $dif to $npc_dex>>\
<<if $res gte $dif or $stun is 1>><<set $combat to 0>><<goto "Start">>\
<<else>><<replace "#c_op">><<= "You failed to run from the "+$npc+". It attacks you.">><</replace>><<npc_att>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<</replace>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</widget>><<= $name + " (" + $class.toUpperFirst()+ " level "+$level+")">>
<<if $modstr is 0>>STR:<<= $str + $modstr>>\
<<elseif $modstr gt 0>>@@color:limegreen;STR:<<= $str + $modstr>>@@<<elseif $modstr lt 0>>@@color:red;STR:<<= $str + $modstr>>@@<</if>> \
<<if $moddex is 0>>DEX:<<= $dex + $moddex>>\
<<elseif $moddex gt 0>>@@color:limegreen;DEX:<<= $dex + $moddex>>@@<<elseif $moddex lt 0>>@@color:red;DEX:<<= $dex + $moddex>>@@<</if>> \
<<if $modwit is 0>>WIT:<<= $wit + $modwit>>\
<<elseif $modwit gt 0>>@@color:limegreen;WIT:<<= $wit + $modwit>>@@<<elseif $modwit lt 0>>@@color:red;WIT:<<= $wit + $modwit>>@@<</if>> \
<<if $hp gt 5>>HP:<<= $hp + "/" + $maxhp>><<else>>@@color:red;HP:<<= $hp + "/" + $maxhp>>@@<</if>>
<<if $hp lt $next>>XP:<<= $xp>><<else>>@@color:limegreen;XP:<<= $xp>>@@<</if>> \
Cred:<<= $cred>> \
Snac:<<= $snacks>> \
Batt:<<= $batt>>
Tools: <<for _a to 0; _a lt $tool.length; _a++>><<tool_use _a '[$tool[_a]]'>><</for>>
<<switch $class>>\
<<case "human">>\
Features: <<= $feat1+" and "+$feat2>>
<<case "alien">>\
Features: <<= $feat1+" and "+$feat2>>
Misfortune: <<= $misf>>
<<case "robot">>\
Function: <<= $util>>
Obsession: <<= $obs>>
<<case "freak">>\
Features: <<= $feat1+" and "+$feat2>>
<</switch>>\
Favorite snack: <<= $favsnack>><<set $tes to 10>><<set $dif to 10>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 11>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 12>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 13>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 14>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 15>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 16>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 17>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 18>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 19>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 20>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<span id="stats"><<include "Stats">></span>
<<set $price to 100>><<set $tries to 0>>\
You found a Snack Machine. You can buy a snack for $price credits.
<span id="op"></span>
<<set $machine to []>><<set $d1 to random(1,10)>><<set $t to random(1,6)>>\
<<if $t is 1>><<set $type to $kind.random()>>\
<<for _n to 0; _n lt $d1; _n++>><<run $machine.push ($type + " " + $food.random() + " " + $form.random())>><</for>>\
<<elseif $t is 2>><<set $type to $food.random()>>\
<<for _n to 0; _n lt $d1; _n++>><<run $machine.push ($kind.random() + " " + $type + " " + $form.random())>><</for>>\
<<elseif $t is 3>><<set $type to $form.random()>>\
<<for _n to 0; _n lt $d1; _n++>><<run $machine.push ($kind.random() + " " + $food.random() + " " + $type)>><</for>>\
<<else>>\
<<for _n to 0; _n lt $d1; _n++>><<run $machine.push ($kind.random() + " " + $food.random() + " " + $form.random())>><</for>>\
<</if>>\
<<run $machine.sort(function (a, b) {return a.localeCompare(b);})>>\
<<link "[Look]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $t is 1>><<replace "#op">>This is the All <<= $type.toUpperFirst()>> snack machine.<</replace>>\
<<elseif $t is 2>><<replace "#op">>This is the <<= $type.toUpperFirst()>> Only snack machine.<</replace>>\
<<elseif $t is 3>><<replace "#op">>This is the Just <<= $type.toUpperFirst()>> snack machine.<</replace>>\
<<else>><<replace "#op">>This is a generic snack machine.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Buy]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $machine.length gt 0>>\
<<replace "#op2">>
Choose a snack to buy:
<<for _n to 0; _n lt $machine.length; _n++>>\
<<link_buy _n '[$machine[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>The machine has no more snacks.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Steal]">>\
<<if $snacks lt 10>>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<set $tries++>>\
<<roll $dex $moddex>><<set $dif to 15>>\
<<if $machine.length gt 0 and $res gte $dif>><<set $rndsnack to $machine.pluck()>>\
<<set $snacks++>><<run $bag.push($rndsnack)>>\
<<replace "#op">>Somehow you got the $rndsnack for free.<</replace>><<set $xp += 50>>\
<<if $rndsnack is $favsnack>><<set $xp += 450>><<append "#op">><<= " And it is your favorite! What luck! (+500xp)">><</append>><<set $favfound++>><</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<elseif $res lt $dif>><<replace "#op">>You failed to steal the snacks.<</replace>>\
<<elseif $machine.length is 0>><<replace "#op">>The machine has no more snacks.<</replace>>\
<</if>>\
<<roll 10 $tries>><<set $dif to $dex + $moddex>>\
<<if $res gte $dif>><<set $combat to 1>>\
<<set $npc to "robot guard">><<set $npc_class to "robot">><<set $npc_str to 20>><<set $npc_dex to 10>><<set $npc_wit to 10>><<set $npc_hp to 10>><<set $npc_xp to 250>>\
<<replace "#c_op">>The $npc appears and attacks you.<</replace>><<timed 0.1s>><<combat>><</timed>>\
<</if>>\
<</if>>\
<<else>><<replace "#op">>You cannot carry any more snacks.<</replace>>\
<</if>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
<<set $price to 100>><<set $price2 to 75>><<set $tries to 0>><<set $sec_a to 0>><<set $sec_b to 0>>\
You found a Snack Store. You can buy a snack for $price credits, or $price2 if on sale.
<span id="op"></span>
<<set $store to []>><<set $d1 to random(10,100)>><<set $t to random(1,6)>>\
<<if $t is 1>><<set $type to $kind.random()>>\
<<for _n to 0; _n lt $d1; _n++>><<run $store.push ($type + " " + $food.random() + " " + $form.random())>><</for>>\
<<elseif $t is 2>><<set $type to $food.random()>>\
<<for _n to 0; _n lt $d1; _n++>><<run $store.push ($kind.random() + " " + $type + " " + $form.random())>><</for>>\
<<elseif $t is 3>><<set $type to $form.random()>>\
<<for _n to 0; _n lt $d1; _n++>><<run $store.push ($kind.random() + " " + $food.random() + " " + $type)>><</for>>\
<<else>>\
<<for _n to 0; _n lt $d1; _n++>><<run $store.push ($kind.random() + " " + $food.random() + " " + $form.random())>><</for>>\
<</if>>\
<<set $sale to $store.randomMany(random(1,10))>>\
<<run $store.sort(function (a, b) {return a.localeCompare(b);})>>\
<<link "[Look]">>\
<<if $combat is 1>>\
<<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $t is 1>><<replace "#op">>This is the All <<= $type.toUpperFirst()>> snack store.<</replace>>\
<<elseif $t is 2>><<replace "#op">>This is the <<= $type.toUpperFirst()>> Only snack store.<</replace>>\
<<elseif $t is 3>><<replace "#op">>This is the Just <<= $type.toUpperFirst()>> snack store.<</replace>>\
<<else>><<replace "#op">>This is a generic snack store.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Buy]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $store.length gt 0>>\
<<if $store.length gt $sec_b>><<set $sec_a to $sec_b>><<set $sec_b += 10>><</if>>\
<<replace "#op2">>
Choose a snack to buy:
<<for _n to $sec_a; _n lt $sec_b; _n++>>\
<<if _n lt $store.length>><<link_store _n '[$store[_n]]'>>\<</if>>\
<</for>>
Press "Buy" again to go to the next section
<</replace>>\
<<if $store.length lte $sec_b>><<set $sec_a to 0>><<set $sec_b to 0>><</if>>\
<<else>><<replace "#op">>The store has no more snacks.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Sale]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $store.length gt 0>>\
<<replace "#op2">>
The following snacks are on sale for half the price:
<<for _n to 0; _n lt $store.length; _n++>>\
<<if $sale.includes($store[_n])>><<link_store _n '[$store[_n]]'>><</if>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>The store has no more snacks.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Steal]">>\
<<if $snacks lt 10>>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<set $tries++>>\
<<roll $dex $moddex>><<set $dif to 15>>\
<<if $store.length gt 0 and $res gte $dif>><<set $rndsnack to $store.pluck()>>\
<<set $snacks++>><<run $bag.push($rndsnack)>>\
<<replace "#op">>Somehow you got the $rndsnack for free.<</replace>><<set $xp += 50>>\
<<if $rndsnack is $favsnack>><<set $xp += 450>><<append "#op">><<= " And it is your favorite! What luck! (+500xp)">><</append>><<set $favfound++>><</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<elseif $res lt $dif>><<replace "#op">>You failed to steal the snacks.<</replace>>\
<<elseif $store.length is 0>><<replace "#op">>The store has no more snacks.<</replace>>\
<</if>>\
<<roll 10 $tries>><<set $dif to $dex + $moddex>>\
<<if $res gte $dif>><<set $combat to 1>>\
<<set $npc to "robot guard">><<set $npc_class to "robot">><<set $npc_str to 20>><<set $npc_dex to 15>><<set $npc_wit to 10>><<set $npc_hp to 15>><<set $npc_xp to 300>>\
<<replace "#c_op">>The $npc appears and attacks you.<</replace>><<timed 0.1s>><<combat>><</timed>>\
<</if>>\
<</if>>\
<<else>><<replace "#op">>You cannot carry any more snacks.<</replace>>\
<</if>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
You found a Scrapyard. You can make credits here searching for valuable scrap. But be careful of robo-scorpions.
<span id="op"></span>
<<set $scrap to random(2,12)>>\
<<link "[Search]">>\
<<if $hp lt 1 or $combat is 1>>\
<<replace "#op">>You cannot do this right now.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $hp gte 18 and $giant isnot 2>><<set $combat to 1>><<set $giant to 1>>\
<<set $npc to "giant robo-scorpion">><<set $npc_class to "robot">><<set $npc_str to 20>><<set $npc_dex to 15>><<set $npc_wit to 15>><<set $npc_hp to 20>><<set $npc_xp to 350>>\
<<replace "#c_op">>The $npc appears and attacks you.<</replace>><<timed 0.1s>><<combat>><</timed>>\
<<else>>\
<<roll $wit $modwit>><<set $dif to 10>>\
<<if $scrap gt 0 and $res gte $dif>>\
<<set $value to random(10,100)>><<set $cred to $cred + $value>>\
<<replace "#op">>You got $value credits from the scrap.<</replace>><<set $scrap-->><<set $xp += 25>>\
<<else>><<replace "#op">>You could not find any valuable scrap.<</replace>>\
<</if>>\
<<roll 12 0>><<set $dif to $dex + $moddex>>\
<<if $res gte $dif>><<set $dam to 1>><<set $hp -= $dam>><<append "#op">> A robo-scorpion bit you. You lost $dam hp.<</append>>\
<<if $hp lt 1>><<append "#c_op">> You faint.<</append>>\
<<replace "#c_op2">><<link "[Wake up]" "Regeneration Booth">><</link>><</replace>>\
<</if>>\
<</if>>\
<</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<if $class is "robot">>\
<<link "[Repair]">>\
<<if $hp lt 1 or $combat is 1>>\
<<replace "#op">>You cannot do this right now.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<roll $wit $modwit>><<set $dif to 10>>\
<<if $scrap gt 0 and $res gte $dif>>\
<<set $hp += random(1,5)>><<if $hp gt $maxhp>><<set $hp to $maxhp>><</if>>\
<<replace "#op">>You find some scrap and use it to repair yourself.<</replace>><<set $scrap-->>\
<<else>><<replace "#op">>You could not find any scrap to repair yourself.<</replace>>\
<</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<</if>>\
<<link "[Snacks]">>\
<<if $hp lt 1 or $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $hp lt 1 or $combat is 1>><<replace "#op">>You cannot leave.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $hp lt 1 or $combat is 1>><<replace "#op">>You cannot leave.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
<<set $talk to 0>><<set $npc_class to either("human", "alien", "robot", "freak")>><<set $npc to $npc_class>>\
<<switch $npc_class>>\
<<case "human">>\
<<set $npc_name to $human_name.random()+" "+$human_surname.random()>>\
<<set $npc_hate to either("", "", "alien", "robot", "freak", "freak")>><<set $a to "a">>\
<<case "alien">>\
<<set $npc_name to $alien_name.random()+" "+$alien_surname.random()>>\
<<set $npc_hate to either("", "", "human", "robot", "freak", "freak")>><<set $a to "an">>\
<<case "robot">>\
<<set $UniqueLabel to $robot_label.randomMany(2)>>\
<<set $npc_name to $UniqueLabel[0]+random(1,9)+$UniqueLabel[1]+random(1,9)>>\
<<set $npc_hate to either("", "", "human", "alien", "freak", "freak")>><<set $a to "a">>\
<<case "freak">>\
<<set $npc_name to either($human_name.random(), $alien_name.random(), $robot_label.random())>>\
<<set $npc_surname to either($human_surname.random(), $alien_surname.random(), $robot_label.random())>>\
<<set $npc_name to $npc_name + " " + $npc_surname>>\
<<set $npc_hate to either("", "", "human", "robot", "alien", "freak")>><<set $a to "a">>\
<</switch>>\
<<set $npc_look to either("worried", "happy", "friendly", "troubled", "crazy", "scared", "tired", "sad", "angry", "relaxed", "anxious")>>\
<<= "You found "+$a+" "+$npc_class+".">>
<span id="op"></span>
<<set $npc_main to either("strong", "smart", "fast")>><<set $npc_str to random(8,12)>><<set $npc_dex to random(8,12)>><<set $npc_wit to random(8,12)>>\
<<set $npc_hp to 10>><<set $npc_xp to 200>><<set $npc_cred to random(100,500)>>\
<<set $npc_tool to $tool_list.randomMany(4)>><<set $npc_fashion1 to $fashion_head.randomMany(4)>><<set $npc_fashion2 to $fashion_body.randomMany(4)>>\
<<set $npc_body1 to $feat_head.randomMany(4)>><<set $npc_body2 to $feat_body.randomMany(4)>><<set $npc_misf to $misfortune.randomMany(8)>>\
<<set $npc_util to $utility.randomMany(2)>><<set $npc_obs to $obsession.randomMany(2)>><<set $npc_trade to $tool_list.random()>>\
<<set $npc_fav to $kind.random() + " " + $food.random() + " " + $form.random()>>\
<<switch $npc_main>>\
<<case "strong">><<set $npc_str to random(13,20)>><<set $npc_dis to either("dumb", "slow")>>\
<<case "fast">><<set $npc_dex to random(13,20)>><<set $npc_dis to either("weak", "dumb")>>\
<<case "smart">><<set $npc_wit to random(13,20)>><<set $npc_dis to either("weak", "slow")>>\
<</switch>>\
<<switch $npc_dis>>\
<<case "weak">><<set $npc_str to random(3,7)>>\
<<case "slow">><<set $npc_dex to random(3,7)>>\
<<case "dumb">><<set $npc_wit to random(3,7)>>\
<</switch>>\
<<link "[Look]">>\
<<replace "#op">><<= "The "+$npc+" looks "+$npc_main+" but "+$npc_dis+". It also looks "+$npc_look+".">>\
<<if $npc is "human">><<= " It is using "+$npc_fashion1[0]+" and "+$npc_fashion2[0]+".">><</if>>\
<<if $npc is "alien">><<= " It has "+$npc_body1[0]+" and "+$npc_body2[0]+".">><</if>>\
<<if $npc is "freak">><<= " It has "+$npc_body1[0]+" and it is using "+$npc_fashion2[0]+".">><</if>>\
<<if $npc is "robot">><<= " It is trying to "+$npc_util[0]+" and it seems to like "+$npc_obs[0]+".">><</if>>\
<</replace>>\
<</link>> \
<<link "[Talk]">>\
<<if $combat is 1 or $npc_hp lt 1>><<replace "#op">>You cannot do this anymore.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $class is $npc_hate>>\
<<replace "#op">>This $npc hates <<= $class+"s">> and immediately attacks you.<</replace>>\
<<set $combat to 1>><<timed 0.1s>><<combat>><</timed>>\
<<else>>\
<<replace "#op">><<= "The "+$npc+" talks about how delicious is the "+$npc_fav+" and says its name is "+$npc_name+".">><</replace>>\
<<for _n to 0; _n lt 10; _n++>>\
<<if $npc_tool.includes($tool[_n])>><<replace "#op">>The $npc talks about your <<= $tool[_n]>> and you have a pleasant conversation (+250xp).<</replace>>\
<<set $xp += 250>><<run $npc_tool.delete($tool[_n])>><<break>>\
<</if>>\
<</for>>\
<<if $npc_fashion1.includes($feat1)>><<replace "#op">>The $npc likes your <<= $feat1>> and you have a pleasant conversation (+250xp).<</replace>>\
<<set $xp += 250>><<run $npc_fashion1.delete($feat1)>>\
<<elseif $npc_fashion2.includes($feat2)>><<replace "#op">>The $npc likes your <<= $feat2>> and you have a pleasant conversation (+250xp).<</replace>>\
<<set $xp += 250>><<run $npc_fashion2.delete($feat2)>>\
<<elseif $npc_body1.includes($feat1)>><<replace "#op">>The $npc likes your <<= $feat1>> and you have a pleasant conversation (+250xp).<</replace>>\
<<set $xp += 250>><<run $npc_body1.delete($feat1)>>\
<<elseif $npc_body2.includes($feat2)>><<replace "#op">>The $npc likes your <<= $feat2>> and you have a pleasant conversation (+250xp).<</replace>>\
<<set $xp += 250>><<run $npc_body2.delete($feat2)>>\
<<elseif $npc_misf.includes($misf)>><<replace "#op">>The $npc talks about being <<= $misf>> and you have a pleasant conversation (+250xp).<</replace>>\
<<set $xp += 250>><<run $npc_misf.delete($misf)>>\
<<elseif $npc_util.includes($util)>><<replace "#op">>The $npc talks about how to <<= $util>> and you have a pleasant conversation (+250xp).<</replace>>\
<<set $xp += 250>><<run $npc_util.delete($util)>>\
<<elseif $npc_obs.includes($obs)>><<replace "#op">>The $npc talks about <<= $obs>> and you have a pleasant conversation (+250xp).<</replace>>\
<<set $xp += 250>><<run $npc_obs.delete($obs)>>\
<</if>>\
<</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Trade]">>\
<<if $combat is 1 or $npc_hp lt 1 or $npc_trade is "">><<replace "#op">>You cannot do this anymore.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<replace "#op">>The $npc has the $npc_trade to trade.<</replace>>\
<<replace "#op2">>
Choose a tool to trade:
<<for _n to 0; _n lt $tool.length; _n++>>\
<<tool_trade _n '[$tool[_n]]'>>\
<</for>>\
<</replace>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Give snack]">>\
<<if $combat is 1 or $npc_hp lt 1>><<replace "#op">>You cannot do this anymore.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<replace "#op2">>
Choose a snack to give:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<snack_give _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Steal]">>\
<<if $combat is 1 or $npc_hp lt 1 or $npc_cred is 0>><<replace "#op">>You cannot do this anymore.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<roll $dex $moddex>><<set $dif to $npc_dex>>\
<<if $res gte $dif>><<set $cred += $npc_cred>><<replace "#op">><<= "You steal "+$npc_cred+" credits from the "+$npc+".">><</replace>><<set $npc_cred to 0>>\
<<else>><<replace "#op">><<= "You failed to steal from the "+$npc+".">><</replace>>\
<</if>>\
<<roll $npc_wit 0>><<set $dif to $dex + $moddex>>\
<<if $res gte $dif>><<replace "#op">>The $npc caught you stealing and immediately attacks.<</replace>>\
<<set $combat to 1>><<timed 0.1s>><<combat>><</timed>>\
<</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
<<set $price to 1000>><<set $price2 to 500>><<set $price3 to 200>><<set $tries to 0>>\
You found a Tool Store. You can buy a tool for $price credits or sell one for $price2 credits. You can also buy a pack of 3 batteries for $price3 credits.
<span id="op"></span>
<<set $tool_store to $tool_list.randomMany(4)>>\
<<link "[Look]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#c_op">><</replace>><<replace "#op">>This store sells: <<= $tool_store.join(', ')>><</replace>>\
<</if>>\
<</link>> \
<<link "[Buy]">>\
<<if $tool_store.length gt 0>>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<replace "#op2">>
Choose a tool to buy:
<<for _n to 0; _n lt $tool_store.length; _n++>>\
<<tool_buy _n '[$tool_store[_n]]'>>\
<</for>>\
<</replace>>\
<</if>>\
<<else>><<replace "#op">>The store has no more tools.<</replace>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Sell]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $tool.length gt 0>>\
<<replace "#op2">>
Choose a tool to sell:
<<for _n to 0; _n lt $tool.length; _n++>><<tool_sell _n '[$tool[_n]]'>><</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no tool to sell.<</replace>>\
<</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Buy Batteries]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $cred gte $price3>>\
<<set $batt += 3>><<set $cred -= $price3>><<replace "#op">>You got 3 new batteries.<</replace>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<else>><<replace "#op">>You cannot afford the batteries.<</replace>>\
<</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Steal]">>\
<<if $tool_store.length gt 0>>\
<<if $combat is 1>>\
<<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<set $tries++>>\
<<roll $dex $moddex>><<set $dif to 20>>\
<<if $res gte $dif>><<set $rndtool to $tool_store.pluck()>>\
<<run $tool.push($rndtool)>>\
<<replace "#op">>Somehow you got the $rndtool for free.<</replace>><<set $xp += 250>>\
<<if $rndtool is $part>><<set $xp += 250>><<append "#op">><<= " It is just what you needed! What luck! (+500xp)">><</append>><</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<elseif $res lt $dif>><<replace "#op">>You failed to steal the tool.<</replace>>\
<</if>>\
<<roll 15 $tries>><<set $dif to $dex>>\
<<if $res gte $dif>><<set $combat to 1>>\
<<set $npc to "robot guard">><<set $npc_class to "robot">><<set $npc_str to 20>><<set $npc_dex to 15>><<set $npc_wit to 15>><<set $npc_hp to 20>><<set $npc_xp to 350>>\
<<replace "#c_op">>The $npc appears and attacks you.<</replace>><<timed 0.1s>><<combat>><</timed>>\
<</if>>\
<</if>>\
<<else>><<replace "#op">>The store has no more tools.<</replace>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
<<set $price to 100>><<set $tries to 0>>\
You found a Battery Machine. You can buy a battery for $price credits.
<span id="op"></span>
<<set $batt_machine to random(3,15)>>\
<<link "[Look]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#c_op">><</replace>><<replace "#op">>This machine has $batt_machine batteries to sell.<</replace>>\
<</if>>\
<</link>> \
<<link "[Buy]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $batt_machine gt 0 and $cred gte $price>>\
<<set $batt++>><<set $batt_machine-->><<set $cred -= $price>><<replace "#op">>You got 1 new battery.<</replace>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<elseif $cred lt $price>><<replace "#op">>You cannot afford the batteries.<</replace>>\
<<elseif $batt_machine is 0>><<replace "#op">>The machine has no more batteries.<</replace>>\
<</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Steal]">>\
<<if $combat is 1>>\
<<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<set $tries++>>\
<<roll $dex $moddex>><<set $dif to 15>>\
<<if $batt_machine gt 0 and $res gte $dif>>\
<<set $batt++>><<set $batt_machine-->><<replace "#op">>Somehow you got 1 battery for free.<</replace>><<set $xp += 50>>\
<<elseif $res lt $dif>><<replace "#op">>You failed to steal the batteries.<</replace>>\
<<elseif $batt_machine is 0>><<replace "#op">>The machine has no more batteries.<</replace>>\
<</if>>\
<<roll 10 $tries>><<set $dif to $dex + $moddex>>\
<<if $res gte $dif>><<set $combat to 1>>\
<<set $npc to "robot guard">><<set $npc_class to "robot">><<set $npc_str to 20>><<set $npc_dex to 10>><<set $npc_wit to 10>><<set $npc_hp to 10>><<set $npc_xp to 250>>\
<<replace "#c_op">>The $npc appears and attacks you.<</replace>><<timed 0.1s>><<combat>><</timed>>\
<</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
<<set $price to 2000>><<set $tries to 0>>\
You found a Shipyard. You can partially repair your ship here for $price credits.
<span id="op"></span>
<<timed 1s>><<if $hp gte 16 and $rival isnot 2>><<set $combat to 1>><<set $rival to 1>><<set $npc to "rival">><<set $npc_class to either("human", "alien", "robot", "freak")>>\
<<set $npc_str to random(14,18)>><<set $npc_dex to random(14,18)>><<set $npc_wit to random(14,18)>><<set $npc_hp to 16>><<set $npc_xp to 320>>\
<<replace "#c_op">>Your $npc_class $npc appears and attacks you.<</replace>><<combat>><</if>><</timed>>\
<<link "[Repair Ship]">>\
<<if $combat is 1>><<replace "#op">>You cannot do this while in combat.<</replace>>\
<<else>>
<<if $ship lt 100>>\
<<if $cred gte $price>>\
<<set $ship += 10>><<set $xp += 500>><<set $cred -= $price>>\
<<replace "#op">>You hire a mechanic to repair your ship.<</replace>>\
<<if $ship gte 100>><<set $ship to 100>>\
<<append "#op">> You did it! The ship is fully functional.<</append>><<set $xp += 1000>>\
<<else>><<append "#op">> You are one step closer to get out of this planet. The ship is <<= $ship+"%">> functional.<</append>>\
<</if>>\
<<else>><<replace "#op">>You cannot afford the repair.<</replace>>\
<</if>>\
<<else>><<replace "#op">>Your ship is already fully functional.<</replace>>\
<</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
<<set $price to 750>><<set $tries to 0>>\
<<set $tool_zone to $tool_list.randomMany(3)>>\
<<set $npc_class to either("human", "alien", "robot", "freak")>><<set $npc to $npc_class>>\
<<switch $npc_class>>\
<<case "human">><<set $npc_hate to either("alien", "robot", "freak", "freak")>>\
<<case "alien">><<set $npc_hate to either("human", "robot", "freak", "freak")>>\
<<case "robot">><<set $npc_hate to either("human", "alien", "freak", "freak")>>\
<<case "freak">><<set $npc_hate to either("human", "robot", "alien", "freak")>>\
<</switch>>\
You found a Dangerous Zone. It is controlled by <<= $npc_class+"s">>. You can buy or sell tools here for <<= $price>> credits.
<span id="op"></span>
<<timed 1s>><<if $hp gte 20 and $master isnot 2>><<set $combat to 1>><<set $master to 1>><<set $npc to "master">>\
<<set $npc_str to random(16,20)>><<set $npc_dex to random(14,18)>><<set $npc_wit to random(14,18)>><<set $npc_hp to 25>>\
<<set $npc_xp to ($npc_str+$npc_dex+$npc_wit+$npc_hp)*5>>\
<<replace "#c_op">>Your $npc_class $npc appears and attacks you.<</replace>><<combat>><</if>><</timed>>\
<<link "[Look]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#c_op">><</replace>><<replace "#op">>We deal with: <<= $tool_zone.join(', ')>><</replace>>\
<<roll $wit $modwit>><<set $dif to 10+$tries>>\
<<if $res gte $dif and $class is $npc_hate>><<set $combat to 1>>\
<<set $npc_str to random(5,15)>><<set $npc_dex to random(5,15)>><<set $npc_wit to random(5,15)>><<set $npc_hp to 10>><<set $npc_xp to 200>>\
<<replace "#c_op">>A hostile $npc_class appears and attacks you.<</replace>><<timed 0.1s>><<combat>><</timed>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Buy]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<roll $wit $modwit>><<set $dif to 10+$tries>>\
<<if $res gte $dif and $class is $npc_hate>><<set $combat to 1>>\
<<set $npc_str to random(5,15)>><<set $npc_dex to random(5,15)>><<set $npc_wit to random(5,15)>><<set $npc_hp to 10>><<set $npc_xp to 200>>\
<<replace "#c_op">>A hostile $npc_class appears and attacks you.<</replace>><<timed 0.1s>><<combat>><</timed>>\
<<else>>\
<<replace "#op2">>
Choose a tool to buy:
<<for _n to 0; _n lt $tool_zone.length; _n++>>\
<<zone_buy _n '[$tool_zone[_n]]'>>\
<</for>>\
<</replace>>\
<</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Sell]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<roll $wit $modwit>><<set $dif to 10+$tries>>\
<<if $res gte $dif and $class is $npc_hate>><<set $combat to 1>>\
<<set $npc_str to random(5,15)>><<set $npc_dex to random(5,15)>><<set $npc_wit to random(5,15)>><<set $npc_hp to 10>><<set $npc_xp to 200>>\
<<replace "#c_op">>A hostile $npc_class appears and attacks you.<</replace>><<timed 0.1s>><<combat>><</timed>>\
<<else>>\
<<if $tool.length gt 0>>\
<<replace "#op2">>
Choose a tool to sell:
<<for _n to 0; _n lt $tool.length; _n++>>\
<<zone_sell _n '[$tool[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no tool to sell.<</replace>>\
<</if>>\
<</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Steal]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<roll $wit $modwit>><<set $dif to 10+$tries>>\
<<if $res gte $dif and $class is $npc_hate>><<set $combat to 1>>\
<<set $npc_str to random(5,15)>><<set $npc_dex to random(5,15)>><<set $npc_wit to random(5,15)>><<set $npc_hp to 10>><<set $npc_xp to 200>>\
<<replace "#c_op">>A hostile $npc_class appears and attacks you.<</replace>><<timed 0.1s>><<combat>><</timed>>\
<<else>>\
<<set $tries++>>\
<<roll $dex $moddex>><<set $dif to 14+$tries>>\
<<if $res gte $dif>><<set $rndtool to $tool_store.pluck()>>\
<<run $tool.push($rndtool)>>\
<<replace "#op">>Somehow you got the $rndtool for free.<</replace>><<set $xp += 250>>\
<<if $rndtool is $part>><<set $xp += 250>><<append "#op">><<= " It is just what you needed! What luck! (+500xp)">><</append>><</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<elseif $res lt $dif>><<replace "#op">>You failed to steal the tool.<</replace>>\
<</if>>\
<<roll 12 $tries>><<set $dif to $dex + $moddex>>\
<<if $res gte $dif>><<set $combat to 1>>\
<<set $npc to $npc +" guard">><<set $npc_str to 18>><<set $npc_dex to 15>><<set $npc_wit to 12>><<set $npc_hp to 20>><<set $npc_xp to 325>>\
<<replace "#c_op">>The $npc appears and attacks you.<</replace>><<timed 0.1s>><<combat>><</timed>>\
<</if>>\
<</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
You found The Arena. You can fight here to get credits.
<span id="op"></span>
<<link "[Look]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#c_op">><</replace>><<replace "#op">>Fights you have won: <<= $arena_level-1>>. The prize for the next fight is <<= 500*$arena_level>> credits.<</replace>>\
<</if>>\
<</link>> \
<<link "[Fight]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<set $npc_class to either("human", "alien", "robot", "freak")>><<set $npc to $npc_class>><<set $combat to 1>><<set $arena to 1>><<set $prize to 500*$arena_level>>\
<<set $npc_str to random(5,15)+$arena_level>><<set $npc_dex to random(5,15)+$arena_level>><<set $npc_wit to random(5,15)+$arena_level>><<set $npc_hp to 10+(2*$arena_level)>><<set $npc_xp to 200+(50*$arena_level)>>\
<<replace "#c_op">>You fight the $npc in the arena.<</replace>><<timed 0.1s>><<combat>><</timed>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
<<set $fight to 0>><<set $winner to 0>><<set $bet to 0>><<set $bet_value to 0>>\
<<set $UniqueLabel to $robot_label.randomMany(2)>>\
<<set $fighter1 to $UniqueLabel[0]+random(1,9)+$UniqueLabel[1]+random(1,9)>>\
<<set $UniqueLabel to $robot_label.randomMany(2)>>\
<<set $fighter2 to $UniqueLabel[0]+random(1,9)+$UniqueLabel[1]+random(1,9)>>\
<<set $fighter1_str to random(15,20)>><<set $fighter2_str to random(15,20)>>\
<<set $fighter1_dex to random(10,15)>><<set $fighter2_dex to random(10,15)>>\
<<set $fighter1_wit to random(5,10)>><<set $fighter2_wit to random(5,10)>>\
<<set $fighter1_hp to random(20,25)>><<set $fighter2_hp to random(20,25)>>\
You found The Robot Boxing Stadium. You can bet on fights here.
<span id="op"></span>
<<link "[Look]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op">>The next fight is between <<= $fighter1>> and <<= $fighter2>>.<</replace>>\
<</if>>\
<<if $fight is 1>><<replace "#op">>The fight between <<= $fighter1>> and <<= $fighter2>> is happening now.<</replace>><</if>>\
<<if $fight is 2>><<replace "#op">>The fight between <<= $fighter1>> and <<= $fighter2>> is over.<</replace>><</if>>\
<</link>> \
<<link "[Bet]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<elseif $fight isnot 0>>\
<<if $bet is 0>><<replace "#op">>You cannot bet anymore.<</replace>>\
<<elseif $bet is 1>><<replace "#op">>You are betting on <<= $fighter1>>.<</replace>>\
<<elseif $bet is 2>><<replace "#op">>You are betting on <<= $fighter2>>.<</replace>>\
<</if>>\
<<elseif $cred lt 100>><<replace "#op">>Not enough credits to bet.<</replace>>\
<<elseif $fight is 0>><<set $bet_value to 100>>\
<<replace "#op2">>
Choose a fighter:
<<link '[$fighter1]'>>\
<<set $bet to 1>><<replace "#op">>You are betting on <<= $fighter1>>.<</replace>>\
<</link>> \
<<link '[$fighter2]'>>\
<<set $bet to 2>><<replace "#op">>You are betting on <<= $fighter2>>.<</replace>>\
<</link>> \
<</replace>>\
<<replace "#c_op">>
Amount to bet: $bet_value<</replace>>\
<<replace "#c_op2">>\
<<link "Raise bet by 100">>\
<<if $cred gte $bet_value+100>><<set $bet_value += 100>>\
<<else>><<replace "#op">>Not enough credits to raise bet.<</replace>>\
<</if>>\
<<replace "#c_op">>
Amount to bet: $bet_value<</replace>>\
<</link>> \
<</replace>>\
<</if>>\
<</link>> \
<<link "[Watch]">>\
<<if $fight is 2>><<replace "#op">>No more fights for tonight.<</replace>><<else>>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<elseif $fight is 1>><<replace "#op">>You are watching the fight.<</replace>>\
<<else>><<set $fight to 1>><<set $round to 1>><<replace "#c_op2">><</replace>>\
<<set $rec1 to Math.trunc($fighter1_wit / 3)>><<set $rec2 to Math.trunc($fighter2_wit / 3)>>\
<<replace "#op2">>
$fighter1 and $fighter2 are ready to fight.<</replace>>\
<<replace "#c_op">>
<<link '[Watch a round]'>>\
<<roll $fighter1_dex 0>><<set $res to $res1>><<roll $fighter2_dex 0>><<set $res to $res2>>\
<<if $res1 gt $res2>><<set $first to 1>>\
<<elseif $res2 gt $res1>><<set $first to 2>>\
<<elseif $res1 is $res2>><<set $first to random(1,2)>>\
<</if>>\
<<if $first is 1>>\
<<roll $fighter1_str 0>><<set $dam to $res-$fighter2_str>><<set $dam to $dam.clamp(1,5)>><<set $fighter2_hp -= $dam>>\
<<if $fighter2_hp lt 1>><<set $winner to 1>><<replace "#op2">>
$fighter1 hits hard. $fighter2 is down. The fight is over. $fighter1 is the winner.<</replace>><<else>>\
<<roll $fighter2_str 0>><<set $dam to $res-$fighter1_str>><<set $dam to $dam.clamp(1,5)>><<set $fighter1_hp -= $dam>>\
<<if $fighter1_hp lt 1>><<set $winner to 2>><<replace "#op2">>
$fighter2 hits hard. $fighter1 is down. The fight is over. $fighter2 is the winner.<</replace>><</if>><</if>>\
<<else>>\
<<roll $fighter2_str 0>><<set $dam to $res-$fighter1_str>><<set $dam to $dam.clamp(1,5)>><<set $fighter1_hp -= $dam>>\
<<if $fighter1_hp lt 1>><<set $winner to 2>><<replace "#op2">>
$fighter2 hits hard. $fighter1 is down. The fight is over. $fighter2 is the winner.<</replace>><<else>>\
<<roll $fighter1_str 0>><<set $dam to $res-$fighter2_str>><<set $dam to $dam.clamp(1,5)>><<set $fighter2_hp -= $dam>>\
<<if $fighter2_hp lt 1>><<set $winner to 1>><<replace "#op2">>
$fighter1 hits hard. $fighter2 is down. The fight is over. $fighter1 is the winner.<</replace>><</if>><</if>>\
<</if>>\
<<if $fighter1_hp gt 0 and $fighter2_hp gt 0>>\
<<set $fighter1_hp += random(0, $rec1)>><<set $fighter2_hp += random(0, $rec2)>>\
<<if $rec1 gt 0>><<set $rec1-->><</if>><<if $rec2 gt 0>><<set $rec2-->><</if>>\
<<if $fighter1_hp gte 15>><<set $cond1 to "solid">><<elseif $fighter1_hp gte 10>><<set $cond1 to "tired">>\
<<elseif $fighter1_hp gte 5>><<set $cond1 to "exhausted">><<elseif $fighter1_hp lt 5>><<set $cond1 to "about to drop">><</if>>\
<<if $fighter2_hp gte 15>><<set $cond2 to "solid">><<elseif $fighter2_hp gte 10>><<set $cond2 to "tired">>\
<<elseif $fighter2_hp gte 5>><<set $cond2 to "exhausted">><<elseif $fighter2_hp lt 5>><<set $cond2 to "about to drop">><</if>>\
<<replace "#op2">>
Round $round is over. $fighter1 looks $cond1 and $fighter2 looks $cond2 as the bell rings.<</replace>><<set $round++>>\
<<else>>\
<<if $bet is $winner>>\
<<set $cred += $bet_value>><<replace "#op">>You won $bet_value credits.<</replace>><<set $bet to 0>>\
<<elseif $bet isnot 0>>\
<<set $cred -= $bet_value>><<replace "#op">>You lost $bet_value credits.<</replace>><<set $bet to 0>>\
<</if>>\
<<set $fight to 2>><<replace"#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1 or $fight is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1 or $fight is 1>><<replace "#op">>You cannot leave.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1 or $fight is 1>><<replace "#op">>You cannot leave.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
<<set $racer to []>><<set $racer_class to []>><<set $racer_nick to []>><<set $racer_dex to []>><<set $racer_wit to []>>\
<<set $race to 0>><<set $bet to -1>><<set $bet_value to 0>>\
<<for _n to 0; _n lt 4; _n++>><<set $racer_class[_n] to either("human", "alien", "robot", "freak")>>\
<<set $racer_dex[_n] to random(10,20)>><<set $racer_wit[_n] to random(10,20)>>\
<<switch $racer_class[_n]>>\
<<case "human">><<set $racer_nick[_n] to $human_surname.random()>><<set $racer[_n] to $human_name.random()+" "+$racer_nick[_n]>>\
<<case "alien">><<set $racer_nick[_n] to $alien_surname.random()>><<set $racer[_n] to $alien_name.random()+" "+$racer_nick[_n]>>\
<<case "robot">><<set $UniqueLabel to $robot_label.randomMany(2)>><<set $racer[_n] to $UniqueLabel[0]+random(1,9)+$UniqueLabel[1]+random(1,9)>>\
<<set $racer_nick[_n] to $racer[_n]>>\
<<case "freak">><<set $racer[_n] to either($human_name.random(), $alien_name.random(), $robot_label.random())>>\
<<set $racer_nick[_n] to either($human_surname.random(), $alien_surname.random(), $robot_label.random())>><<set $racer[_n] to $racer[_n] + " " + $racer_nick[_n]>>\
<</switch>>\
<</for>>\
You found The Jet Pack Racing Club. You can bet on races here.
<span id="op"></span>
<<link "[Look]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op">>Racers competing in the next race: <<= $racer[0]>>, <<= $racer[1]>>, <<= $racer[2]>> and <<= $racer[3]>>.<</replace>>\
<</if>>\
<<if $race is 1>><<replace "#op">>The race is on.<</replace>><</if>>\
<<if $race is 2>><<replace "#op">>The race is over.<</replace>><</if>>\
<</link>> \
<<link "[Bet]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<elseif $race isnot 0>>\
<<if $bet is -1>><<replace "#op">>You cannot bet anymore.<</replace>>\
<<else>><<replace "#op">>You are betting on <<= $racer[$bet]>>.<</replace>>\
<</if>>\
<<elseif $cred lt 100>><<replace "#op">>Not enough credits to bet.<</replace>>\
<<elseif $race is 0>><<set $bet_value to 100>>\
<<replace "#op2">>
Choose a racer:
<<for _n to 0; _n lt 4; _n++>>\
<<link_racer _n '[$racer[_n]]'>>
<</for>>\
<</replace>>\
<<replace "#c_op">>
Amount to bet: $bet_value<</replace>>\
<<replace "#c_op2">>\
<<link "Raise bet by 100">>\
<<if $cred gte $bet_value+100>><<set $bet_value += 100>>\
<<else>><<replace "#op">>Not enough credits to raise bet.<</replace>>\
<</if>>\
<<replace "#c_op">>
Amount to bet: $bet_value<</replace>>\
<</link>> \
<</replace>>\
<</if>>\
<</link>> \
<<link "[Watch]">>\
<<if $race is 2>><<replace "#op">>No more races for today.<</replace>>\
<<else>>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<elseif $race is 1>><<replace "#op">>You are watching the race.<</replace>>\
<<elseif $race is 0>><<set $race to 1>><<replace"#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<set $vel to [0, 0, 0, 0]>><<set $dist to [0, 0, 0, 0]>><<set $brake to [0, 0, 0, 0]>><<set $fin to [0, 0, 0, 0]>><<set $pos to [4, 4, 4, 4]>>\
<<replace "#op2">>
1. $racer_nick[0] | 2. $racer_nick[1] | 3. $racer_nick[2] | 4. $racer_nick[3]<</replace>>\
<<repeat 0.3s>>\
<<for _n to 0; _n lt 4; _n++>>\
<<if $dist[_n] lt 50>>\
<<roll $racer_dex[_n] 0>><<set $vel[_n] to $res-(10+ $brake[_n])>><<set $vel[_n] to Math.trunc($vel[_n]/ 2)>>\
<<if $vel[_n] lt 1>><<set $vel[_n] to 1>><</if>><<if $vel[_n] gt 3>><<set $vel[_n] to 3>><</if>>\
<<roll $racer_wit[_n] 0>><<set $brake[_n] to $vel[_n]-($res-10)>><<if $brake[_n] lt 0>><<set $brake[_n] to 0>><</if>><<if $brake[_n] gt 3>><<set $brake[_n] to 3>><</if>>\
<<set $dist[_n] += $vel[_n]>>\
<<for _d to 0; _d lt $vel[_n]; _d++>>\
<<if _n is 0>><<append "#line1">>.<</append>><</if>><<if _n is 1>><<append "#line2">>.<</append>><</if>>\
<<if _n is 2>><<append "#line3">>.<</append>><</if>><<if _n is 3>><<append "#line4">>.<</append>><</if>>\
<</for>>\
<<else>>\
<<if $fin[_n] is 0>><<set $fin[_n] to 1>>\
<<if $pos[0] is 4>><<set $pos[0] to _n>><<append "#list">>The winner is <<= $racer[$pos[0]]>>.
<</append>>\
<<elseif $pos[1] is 4>><<set $pos[1] to _n>><<append "#list">>Second place to <<= $racer[$pos[1]]>>.
<</append>>\
<<elseif $pos[2] is 4>><<set $pos[2] to _n>><<append "#list">>Third place to <<= $racer[$pos[2]]>>.
<</append>>\
<<elseif $pos[3] is 4>><<set $pos[3] to _n>><<append "#list">>Last place to <<= $racer[$pos[3]]>>.
<</append>>\
<<if $bet is $pos[0]>>\
<<set $bet_value to Math.trunc($bet_value * 1.5)>><<set $cred += $bet_value>><<replace "#op">>You won $bet_value credits.<</replace>><<set $bet to -1>>\
<<elseif $bet is $pos[1]>>\
<<replace "#op">>You get your $bet_value credits back.<</replace>><<set $bet to -1>>\
<<elseif $bet is $pos[2]>>\
<<set $bet_value to Math.trunc($bet_value / 2)>><<set $cred -= $bet_value>><<replace "#op">>You lost $bet_value credits.<</replace>><<set $bet to -1>>\
<<elseif $bet is $pos[3]>>\
<<set $cred -= $bet_value>><<replace "#op">>You lost $bet_value credits.<</replace>><<set $bet to -1>>\
<</if>>\
<<set $race to 2>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<stop>>\
<</if>>\
<</if>>\
<</if>>\
<</for>>\
<</repeat>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1 or $race is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#line1">><</replace>><<replace "#line2">><</replace>><<replace "#line3">><</replace>><<replace "#line4">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1 or $race is 1>><<replace "#op">>You cannot leave.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1 or $race is 1>><<replace "#op">>You cannot leave.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="line1"></span>
<span id="c_op2"></span><span id="line2"></span>
<span id="line3"></span>
<span id="line4"></span>
<span id="list"></span>
<span id="stats"><<include "Stats">></span>
<<set $price to 125>><<set $activity to either("arm-wrestling", "darts", "checkers")>>\
You found a Cantina. You can eat a snack here for $price credits or try a contest of $activity.
<span id="op"></span>
<<set $kitchen to []>><<set $d1 to random(3,6)>>\
<<for _n to 0; _n lt $d1; _n++>><<run $kitchen.push ($kind.random() + " " + $food.random() + " " + $form.random())>><</for>>\
<<set $cantina to $alien_surname.random()>>\
<<timed 1s>><<if $hp gte 15 and $enemy isnot 2 and $class is "alien">><<set $combat to 1>><<set $enemy to 1>><<set $npc to "enemy">>\
<<set $npc_class to either("human", "alien", "robot", "freak")>>\
<<set $npc_str to random(16,20)>><<set $npc_dex to random(16,20)>><<set $npc_wit to random(16,20)>><<set $npc_hp to random(16,20)>>\
<<set $npc_xp to ($npc_str+$npc_dex+$npc_wit+$npc_hp)*5>>\
<<replace "#c_op">>The $npc_class responsible for your misfortune appears and attacks you.<</replace>><<combat>><</if>><</timed>>\
<<link "[Look]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>><<else>>\
<<set $cantina_msg to either("We are open 35 ticks/cycle.","You have to pay in advance.","Don't pick up fights here.")>>\
<<replace "#op">>Welcome to the $cantina cantina. $cantina_msg<</replace>>\
<</if>>\
<</link>> \
<<link "[Eat]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>><<else>>\
<<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
<<= "Today's menu:">>
<<for _n to 0; _n lt $kitchen.length; _n++>>\
<<link_cantina _n '[$kitchen[_n]]'>>\
<</for>>
<</replace>>\
<</if>>\
<</link>> \
<<if $activity is "arm-wrestling">>\
<<link "[Arm-wrestling]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>><<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<replace "#op2">>
Your record at arm-wrestling is $arm_rec straight wins.
<<link "[Try to beat]">>\
<<replace "#op2">><</replace>>\
<<set $wins to 0>><<set $lost to 0>>\
<<repeat 0.5s>><<roll $str $modstr>>\
<<if $res gte random(10,15)>><<set $wins++>><<replace "#c_op">>Straight wins: $wins<</replace>><<else>>\
<<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<replace "#op">>You got $wins straight wins at arm-wrestling.<</replace>>\
<<if $wins gt $arm_rec>><<append "#op">> New record!<</append>><<set $arm_rec to $wins>><<set $xp += 50*$wins>><</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<stop>>\
<</if>>\
<</repeat>>\
<</link>> \
<</replace>>
<</if>>\
<</link>> \
<</if>>\
<<if $activity is "darts">>\
<<link "[Darts]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>><<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<replace "#op2">>
Your record at darts is $darts_rec straight wins.
<<link "[Try to beat]">>\
<<replace "#op2">><</replace>>\
<<set $wins to 0>><<set $lost to 0>>\
<<repeat 0.5s>><<roll $dex $moddex>>\
<<if $res gte random(10,15)>><<set $wins++>><<replace "#c_op">>Straight wins: $wins<</replace>><<else>>\
<<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<replace "#op">>You got $wins straight wins at darts.<</replace>>\
<<if $wins gt $darts_rec>><<append "#op">> New record!<</append>><<set $darts_rec to $wins>><<set $xp += 50*$wins>><</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<stop>>\
<</if>>\
<</repeat>>\
<</link>> \
<</replace>>
<</if>>\
<</link>> \
<</if>>\
<<if $activity is "checkers">>\
<<link "[Checkers]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>><<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<replace "#op2">>
Your record at checkers is $checkers_rec straight wins.
<<link "[Try to beat]">>\
<<replace "#op2">><</replace>>\
<<set $wins to 0>><<set $lost to 0>>\
<<repeat 0.5s>><<roll $wit $modwit>>\
<<if $res gte random(10,15)>><<set $wins++>><<replace "#c_op">>Straight wins: $wins<</replace>><<else>>\
<<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<replace "#op">>You got $wins straight wins at checkers.<</replace>>\
<<if $wins gt $checkers_rec>><<append "#op">> New record!<</append>><<set $checkers_rec to $wins>><<set $xp += 50*$wins>><</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<stop>>\
<</if>>\
<</repeat>>\
<</link>> \
<</replace>>
<</if>>\
<</link>> \
<</if>>\
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $snacks gt 0>><<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><<set $tes to 10>><<set $dif to 10>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 11>><<set $dif to 10>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 12>><<set $dif to 10>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 13>><<set $dif to 10>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 14>><<set $dif to 10>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 15>><<set $dif to 10>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 16>><<set $dif to 10>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 17>><<set $dif to 10>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 18>><<set $dif to 10>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 19>><<set $dif to 10>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 20>><<set $dif to 10>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 10>><<set $m to -5>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 10>><<set $m to -4>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 10>><<set $m to -3>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 10>><<set $m to -2>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 10>><<set $m to -1>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 10>><<set $m to 0>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 10>><<set $m to 1>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 10>><<set $m to 2>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 10>><<set $m to 3>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 10>><<set $m to 4>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<<set $tes to 10>><<set $dif to 10>><<set $m to 5>>\
Test: $tes Dif: $dif mod $m
<<set $suc to 0>><<set $dam to 0>>\
<<for _i to 0; _i lt 500; _i++>>\
<<roll $tes $m>><<if $res gte $dif>><<set $suc++>><</if>><<set $dam to $dam+$res-$dif>>\
<</for>>\
Chance: <<print $suc/5+"%">> Damage: <<print $dam/500>>
<span id="stats"><<include "Stats">></span>
<<set $price to 250>><<set $price2 to 1500>><<set $exp to random(1,3)>>\
You found The Alien Lab. You can heal for $price credits or make experiments for $price2 credits.
<span id="op"></span>
<<timed 1s>><<if $hp gte 17 and $clone isnot 2>><<set $combat to 1>><<set $clone to 1>><<set $npc to "clone">><<set $npc_class to $class>>\
<<set $npc_str to $str>><<set $npc_dex to $dex>><<set $npc_wit to $wit>><<set $npc_hp to $maxhp>><<set $npc_xp to ($npc_str+$npc_dex+$npc_wit+$npc_hp)*5>>\
<<replace "#c_op">>Your clone appears and attacks you.<</replace>><<combat>><</if>><</timed>>\
<<link "[Look]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>><<else>>\
<<replace "#op">>Warning: the results of the experiments are permanent! Caution advised.<</replace>>\
<</if>>\
<</link>> \
<<link "[Heal]">>\
<<if $hp is $maxhp>><<replace "#op">>No need.<</replace>><<else>>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $cred gte $price>>\
<<set $hp to $maxhp>><<set $cred -= $price>>\
<<replace "#op">><<= "You are healed.">><</replace>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<</if>>\
<</if>>\
<</link>> \
<<if $exp is 1 and $dex gt 3>>\
<<link "[Experiment A]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>><<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $cred gte $price2>><<set $cre -= $price2>>\
<<replace "#op2">>
This experiment can raise your STR is successful. It will drop your DEX if fails.
<<link "[Experiment]">>\
<<replace "#op2">><</replace>>\
<<set $tries to 0>>\
<<repeat 0.5s>><<roll $wit $modwit>>\
<<if $res gte $tries>><<set $tries++>><<append "#c_op">>.<</append>><<else>>\
<<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<replace "#op">>You finished the experiment.<</replace>>\
<<if $tries gt $str>><<append "#op">> Success! +1 STR.<</append>><<set $str ++>><<set $xp += 25 * $tries>>
<<else>><<append "#op">> Failure! -1 DEX.<</append>><<set $dex -->>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<stop>>\
<</if>>\
<</repeat>>\
<</link>> \
<</replace>>
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<</if>>\
<<if $exp is 2 and $wit gt 3>>\
<<link "[Experiment B]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>><<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $cred gte $price2>><<set $cre -= $price2>>\
<<replace "#op2">>
This experiment can raise your DEX is successful. It will drop your WIT if fails.
<<link "[Experiment]">>\
<<replace "#op2">><</replace>>\
<<set $tries to 0>>\
<<repeat 0.5s>><<roll $wit $modwit>>\
<<if $res gte $tries>><<set $tries++>><<append "#c_op">>.<</append>><<else>>\
<<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<replace "#op">>You finished the experiment.<</replace>>\
<<if $tries gt $dex>><<append "#op">> Success! +1 DEX.<</append>><<set $dex ++>><<set $xp += 25 * $tries>>
<<else>><<append "#op">> Failure! -1 WIT.<</append>><<set $wit -->>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<stop>>\
<</if>>\
<</repeat>>\
<</link>> \
<</replace>>
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<</if>>\
<<if $exp is 3 and $str gt 3>>\
<<link "[Experiment C]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>><<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $cred gte $price2>><<set $cre -= $price2>>\
<<replace "#op2">>
This experiment can raise your WIT is successful. It will drop your STR if fails.
<<link "[Experiment]">>\
<<replace "#op2">><</replace>>\
<<set $tries to 0>>\
<<repeat 0.5s>><<roll $wit $modwit>>\
<<if $res gte $tries>><<set $tries++>><<append "#c_op">>.<</append>><<else>>\
<<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<replace "#op">>You finished the experiment.<</replace>>\
<<if $tries gt $wit>><<append "#op">> Success! +1 WIT.<</append>><<set $wit ++>><<set $xp += 25 * $tries>>
<<else>><<append "#op">> Failure! -1 STR.<</append>><<set $str -->>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<stop>>\
<</if>>\
<</repeat>>\
<</link>> \
<</replace>>
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<</if>>\
<<link "[Snacks]">>\
<<replace "#op">>Eating snacks is not allowed in the lab.<</replace>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
<<set $racer to []>><<set $racer_class to []>><<set $racer_nick to []>><<set $racer_dex to []>><<set $racer_wit to []>>\
<<set $race to 0>>\
<<for _n to 0; _n lt 3; _n++>><<set $racer_class[_n] to either("human", "alien", "robot", "freak")>>\
<<set $racer_dex[_n] to random(10,20)>><<set $racer_wit[_n] to random(10,20)>>\
<<switch $racer_class[_n]>>\
<<case "human">><<set $racer_nick[_n] to $human_surname.random()>><<set $racer[_n] to $human_name.random()+" "+$racer_nick[_n]>>\
<<case "alien">><<set $racer_nick[_n] to $alien_surname.random()>><<set $racer[_n] to $alien_name.random()+" "+$racer_nick[_n]>>\
<<case "robot">><<set $UniqueLabel to $robot_label.randomMany(2)>><<set $racer[_n] to $UniqueLabel[0]+random(1,9)+$UniqueLabel[1]+random(1,9)>>\
<<set $racer_nick[_n] to $racer[_n]>>\
<<case "freak">><<set $racer[_n] to either($human_name.random(), $alien_name.random(), $robot_label.random())>>\
<<set $racer_nick[_n] to either($human_surname.random(), $alien_surname.random(), $robot_label.random())>><<set $racer[_n] to $racer[_n] + " " + $racer_nick[_n]>>\
<</switch>>\
<</for>>\
<<set $racer_dex[3] to $dex>><<set $racer_wit[3] to $wit>><<set $racer[3] to $name>><<set $racer_nick[3] to "You">>\
<<set $price to 250>>\
You found The Cyberdrone Racetrack. You can compete on races here for $price credits.
<span id="op"></span>
<<link "[Look]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op">>Racers competing here: <<= $racer[0]>>, <<= $racer[1]>> and <<= $racer[2]>>.<</replace>>\
<</if>>\
<<if $race is 1>><<replace "#op">>The race is on.<</replace>><</if>>\
<<if $race is 2>><<replace "#op">>The race is over.<</replace>><</if>>\
<</link>> \
<<link "[Race]">>\
<<set $racermod1 to [0, 0, 0, $moddex]>><<set $racermod2 to [0, 0, 0, $modwit]>>\
<<if $cred gte $price>>\
<<if $race is 2>><<replace "#op">>No more races for today.<</replace>>\
<<else>>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>>\
<<elseif $race is 1>><<replace "#op">>You are racing.<</replace>>\
<<elseif $race is 0>><<set $race to 1>><<set $cred -= $price>><<replace"#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<set $vel to [0, 0, 0, 0]>><<set $dist to [0, 0, 0, 0]>><<set $brake to [0, 0, 0, 0]>><<set $fin to [0, 0, 0, 0]>><<set $pos to [4, 4, 4, 4]>>\
<<replace "#op2">>
1. $racer_nick[0] | 2. $racer_nick[1] | 3. $racer_nick[2] | 4. $racer_nick[3]<</replace>>\
<<repeat 0.3s>>\
<<for _n to 0; _n lt 4; _n++>>\
<<if $dist[_n] lt 50>>\
<<roll $racer_dex[_n] $racermod1[_n]>><<set $vel[_n] to $res-(10+ $brake[_n])>><<set $vel[_n] to Math.trunc($vel[_n]/ 2)>>\
<<if $vel[_n] lt 1>><<set $vel[_n] to 1>><</if>><<if $vel[_n] gt 3>><<set $vel[_n] to 3>><</if>>\
<<roll $racer_wit[_n] $racermod2[_n]>><<set $brake[_n] to $vel[_n]-($res-10)>><<if $brake[_n] lt 0>><<set $brake[_n] to 0>><</if>><<if $brake[_n] gt 3>><<set $brake[_n] to 3>><</if>>\
<<set $dist[_n] += $vel[_n]>>\
<<for _d to 0; _d lt $vel[_n]; _d++>>\
<<if _n is 0>><<append "#line1">>.<</append>><</if>><<if _n is 1>><<append "#line2">>.<</append>><</if>>\
<<if _n is 2>><<append "#line3">>.<</append>><</if>><<if _n is 3>><<append "#line4">>.<</append>><</if>>\
<</for>>\
<<else>>\
<<if $fin[_n] is 0>><<set $fin[_n] to 1>>\
<<if $pos[0] is 4>><<set $pos[0] to _n>><<append "#list">>The winner is <<= $racer[$pos[0]]>>.
<</append>>\
<<elseif $pos[1] is 4>><<set $pos[1] to _n>><<append "#list">>Second place to <<= $racer[$pos[1]]>>.
<</append>>\
<<elseif $pos[2] is 4>><<set $pos[2] to _n>><<append "#list">>Third place to <<= $racer[$pos[2]]>>.
<</append>>\
<<elseif $pos[3] is 4>><<set $pos[3] to _n>><<append "#list">>Last place to <<= $racer[$pos[3]]>>.
<</append>>\
<<if $name is $racer[$pos[0]]>>\
<<set $cred += 1500>><<replace "#op">>You won 1500 credits.<</replace>>\
<<elseif $name is $racer[$pos[1]]>>\
<<set $cred += 500>><<replace "#op">>You won 500 credits.<</replace>>\
<<elseif $name is $racer[$pos[2]]>>\
<<set $cred += 300>><<replace "#op">>You won 300 credits.<</replace>>\
<<elseif $name is $racer[$pos[3]]>>\
<<replace "#op">>Better luck next time.<</replace>>\
<</if>>\
<<set $race to 2>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<stop>>\
<</if>>\
<</if>>\
<</if>>\
<</for>>\
<</repeat>>\
<</if>>\
<</if>>\
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1 or $race is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#line1">><</replace>><<replace "#line2">><</replace>><<replace "#line3">><</replace>><<replace "#line4">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1 or $race is 1>><<replace "#op">>You cannot leave.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1 or $race is 1>><<replace "#op">>You cannot leave.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="line1"></span>
<span id="c_op2"></span><span id="line2"></span>
<span id="line3"></span>
<span id="line4"></span>
<span id="list"></span>
<span id="stats"><<include "Stats">></span>
<<set $price to 750>><<if $class is "freak">><<set $price to 500>><</if>>\
You found The Freak Body Shop. You can modify your body here for $price credits<<if $class is "freak">> (freak discount)<</if>>.
<span id="op"></span>
<<link "[Look]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<replace "#op">>Warning: the body modification is distressful and has unpredictable results on your stats.<</replace>>\
<</if>>\
<</link>> \
<<link "[Modify]">>\
<<if $class is "robot">><<replace "#op">>It does not work on robots.<</replace>><<else>>\
<<if $hp lt 5 or $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>>\
<<if $cred gte $price>><<set $cre -= $price>><<set $hp -= 3>><<replace "#op">>You try to modify your body. You lost 3 hp. You get <</replace>>\
<<set $d1 to random(1,3)>><<set $value to random(-1,1)>>\
<<if $d1 is 1 and $value isnot 0>><<set $str += $value>><<if $value is 1>><<append "#op">>+1 STR.<</append>><<else>><<append "#op">>-1 STR.<</append>><</if>><</if>>\
<<if $d1 is 2 and $value isnot 0>><<set $dex += $value>><<if $value is 1>><<append "#op">>+1 DEX.<</append>><<else>><<append "#op">>-1 DEX.<</append>><</if>><</if>>\
<<if $d1 is 3 and $value isnot 0>><<set $wit += $value>><<if $value is 1>><<append "#op">>+1 WIT.<</append>><<else>><<append "#op">>-1 WIT.<</append>><</if>><</if>>\
<<if $value is 0>><<append "#op">>no visible change.<</append>><</if >>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
<<set $npc_class to either("human", "alien", "robot", "freak")>><<set $npc to $npc_class>>\
<<set $npc_str to random(5,15)>><<set $npc_dex to random(5,15)>><<set $npc_wit to random(5,15)>><<set $npc_hp to random(10,15)>>\
<<set $npc_cred to random(100,500)>><<set $npc_batt to random(0,3)>><<set $npc_snack to random(0,3)>>\
<<set $npc_xp to ($npc_str+$npc_dex+$npc_wit+$npc_hp)*5>>\
<<roll $wit $modwit>><<set $dif to $npc_dex>>\
<<if $res gte $dif>><<set $combat to 1>>\
<<timed 0.1s>><<replace "#c_op">>A hostile $npc_class appears and attacks you.<</replace>><<combat>><</timed>>\
<<else>><<explore>>\
<</if>>\
Ambush!
<span id="op"></span>
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
<<set $n1 to random(1,9)>><<set $n2 to random(1,9)>><<set $n3 to random(1,9)>>\
<<set $cn1 to random(1,9)>><<set $cn2 to random(1,9)>><<set $cn3 to random(1,9)>><<set $tries to 5>><<set $opened to 0>>\
<<set $cred_locked to random(100,750)>><<set $snack_locked to random(0,3)>><<set $batt_locked to random(0,3)>>\
<<set $d1 to random(1,6)>><<if $d1 gt 4>><<set $tool_locked to $tool_list.random()>><<else>><<set $tool_locked to "">><</if>>\
You found a Magnetic Locked Storage. To open, you have to guess the combination.
<span id="op"></span>
<span id="n1">- - - -[<<cycle "$n1" autoselect>><<option 1>><<option 2>><<option 3>><<option 4>><<option 5>>\
<<option 6>><<option 7>><<option 8>><<option 9>><</cycle>>]- -</span> \
<span id="n2">- -[<<cycle "$n2" autoselect>><<option 1>><<option 2>><<option 3>><<option 4>><<option 5>>\
<<option 6>><<option 7>><<option 8>><<option 9>><</cycle>>]- -</span> \
<span id="n3">- -[<<cycle "$n3" autoselect>><<option 1>><<option 2>><<option 3>><<option 4>><<option 5>>\
<<option 6>><<option 7>><<option 8>><<option 9>><</cycle>>]- - - -</span>
<<link "[Look]">>\
<<if $combat is 1>>\
<<replace "#op">>You cannot do that while in combat.<</replace>>\
<<else>><<replace "#op">>You have $tries tries before it blocks. Green: correct digit and position. Red: this digit is not in any position.<</replace>>
<</if>>\
<</link>> \
<<link "[Open]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that while in combat.<</replace>><<else>>\
<<if $opened is 1>><<replace "#op">>You already opened.<</replace>><<else>>\
<<if $opened is 2>><<replace "#op">>It is blocked.<</replace>><<else>>\
<<if $tries gt 0>><<set $tries-->><<replace "#op2">>
Tries left: $tries<</replace>>\
<<if $n1 is $cn1>><<css '#n1' 'color' 'lime'>><</if>><<if $n2 is $cn2>><<css '#n2' 'color' 'lime'>><</if>><<if $n3 is $cn3>><<css '#n3' 'color' 'lime'>><</if>>\
<<if $n1 isnot $cn1 and $n1 isnot $cn2 and $n1 isnot $cn3>><<css '#n1' 'color' 'red'>><</if>>\
<<if $n2 isnot $cn1 and $n2 isnot $cn2 and $n2 isnot $cn3>><<css '#n2' 'color' 'red'>><</if>>\
<<if $n3 isnot $cn1 and $n3 isnot $cn2 and $n3 isnot $cn3>><<css '#n3' 'color' 'red'>><</if>>\
<<timed 0.5s>><<css '#n1' 'color' 'black'>><<css '#n2' 'color' 'black'>><<css '#n3' 'color' 'black'>><</timed>>\
<<if $n1 is $cn1 and $n2 is $cn2 and $n3 is $cn3>><<set $opened to 1>><<replace "#op">>You opened the lock!<</replace>>\
<<append "#op">> Inside you find: $cred_locked credits<</append >>\
<<if $batt_locked is 1>><<append "#op">>, 1 battery<</append>><<elseif $batt_locked gt 1>><<append "#op">>, $batt_locked batteries<</append>><</if>>\
<<if $bag.length lte 10-$snack_locked>>\
<<if $snack_locked is 1>><<append "#op">>, 1 snack<</append>><<elseif $snack_locked gt 1>><<append "#op">>, $snack_locked snacks<</append>><</if>>\
<<set $snacks += $snack_locked>>\
<<for _n to 0; _n lt $snack_locked; _n++>>\
<<set $rndsnack to $kind.random() + " " + $food.random() + " " + $form.random()>><<run $bag.push($rndsnack)>>\
<<if $rndsnack is $favsnack>><<set $xp += 500>><<append "#op">><<= " Your favorite snack! What luck! (+500xp)">><</append>><<set $favfound++>><</if>>\
<</for>>\
<</if>>\
<<if $tool_locked isnot "">><<if $tool.length lt 5>><<append "#op">> and the $tool_locked.<</append>><<run $tool.push($tool_locked)>><</if>><</if>>\
<<set $cred += $cred_locked>><<set $batt += $batt_locked>>\
<<replace "#stats">><<include "Stats">><</replace>><<replace "#op2">><</replace>>\
<</if>>\
<<else>><<set $opened to 2>><<replace "#op">>It is blocked.<</replace>>\
<</if>>\
<</if>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2">
Tries left: $tries</span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
<<set $price to 200>>\
You found The Workbench. You can make a tool from another tool here for $price credits. It can also repair robots.
<span id="op"></span>
<<link "[Look]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<replace "#op">>You can dismantle a tool to try to make another tool, but you lose it if you fail.<</replace>>\
<</if>>\
<</link>> \
<<link "[Dismantle]">>\
<<if $cred gte $price>><<set $cred -= $price>>\
<<if $tool.length gt 0>>\
<<replace "#op2">>
Choose a tool to dismantle:
<<for _n to 0; _n lt $tool.length; _n++>><<tool_dis _n '[$tool[_n]]'>><</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no tool.<</replace>>\
<</if>>\
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<<if $class is "robot" and $level gt 5>>\
<<link "[Reconfigure]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $cred gte $price>>\
<<replace "#op2">>
Do you wish to reset all ability points you have spent?
<<link "[Confirm]">>\
<<set $str to $ostr>><<set $dex to $odex>><<set $wit to $owit>><<set $points to $level-1>><<set $cred -= $price>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op2">>
Points: <<= $points>>
<<raise_ability>><</replace>>\
<</link>> \
<</replace>>\
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<</if>>\
<<if $class is "robot">>\
<<link "[Full Repair]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>>\
<<else>>\
<<if $cred gte $price>><<set $cred -= $price>><<set $hp to $maxhp>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<replace "#op">>You use The Workbench to repair yourself.<</replace>>\
<<else>><<replace "#op">>You cannot afford.<</replace>>\
<</if>>\
<</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</link>> \
<</if>>\
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
A cloud of Rogue Nanobots appears and it is hungry for technology!
<span id="op"></span>
<<timed 0.1s>><<roll $dex $moddex>>\
<<if $res gte 12>><<replace "#op">>You run before they reach you.<</replace>>\
<<else>><<if $tool.length gt 0>><<set $rndtool to $tool.pluck()>><<replace "#op">>You lost your <<= $rndtool>>.<</replace>><</if>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<</if>><</timed>>\
<<link "[Continue]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><span id="stats"><<include "Stats">></span>
<<set $fixed to 0>><<set $npc_cred to random(100,500)>>\
You found a Broken Robot.
<span id="op"></span>
<<link "[Look]">>\
<<if $fixed is 0>><<replace "#op">>You could repair it with the multi-tools.<</replace>>\
<<elseif $fixed is 1>><<replace "#op">>The robot is thankful for your help.<</replace>>\
<<elseif $fixed is -1>><<replace "#op">>The remains of the robot lie scattered on the ground.<</replace>>\
<</if>>\
<</link>> \
<<link "[Scavenge]">>\
<<if $fixed is 0>><<replace "#op">>You scavenge the robot for valuable parts and get $npc_cred credits.<</replace>>\
<<set $cred += $npc_cred>><<set $fixed to -1>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<else>><<replace "#op">>You cannot do this anymore.<</replace>>\
<</if>>\
<</link>> \
<<link "[Repair]">>\
<<if $fixed is 0 and $tool.includes("multi-tools") and $batt gt 0>><<replace "#op">>You use your multi-tools to repair the robot (+500xp).<</replace>>\
<<set $batt-->><<set $xp += 500>><<set $fixed to 1>>\
<<replace "#stats">><<include "Stats">><</replace>>\
<<else>><<replace "#op">>You cannot do this.<</replace>>\
<</if>>\
<</link>> \
<<link "[Snacks]">>\
<<if $combat is 1>><<replace "#op">>You cannot do that.<</replace>><<else>>\
<<if $snacks gt 0>><<replace "#op2">><</replace>><<replace "#c_op">><</replace>><<replace "#c_op2">><</replace>>\
<<replace "#op2">>
Choose a snack to eat:
<<for _n to 0; _n lt $bag.length; _n++>>\
<<link_eat _n '[$bag[_n]]'>>\
<</for>>\
<</replace>>\
<<else>><<replace "#op">>You have no snacks left. Try to find more out there.<</replace>>\
<</if>>\
<</if>>\
<</link>> \
<<link "[Explore]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<set $enc to 0>><<explore>><</if>>\
<</link>> \
<<link "[Return]">>\
<<if $combat is 1>><<replace "#op">>You cannot leave while in combat. Try to run instead.<</replace>><<else>><<goto "Start">><</if>>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><<set $modstr to 0>><<set $moddex to 0>><<set $modwit to 0>><<set $hp to $maxhp>>\
<<if $arena is 1>><<set $arena to 0>><</if>>\
<<if $giant is 1>><<set $giant to 0>><</if>><<if $rival is 1>><<set $rival to 0>><</if>><<if $clone is 1>><<set $clone to 0>><</if>>\
<<if $enemy is 1>><<set $enemy to 0>><</if>><<if $master is 1>><<set $master to 0>><</if>>\
<span id="stats"><<include "Stats">></span>
You wake up in the Regeneration Booth.
<span id="op"></span>
<<timed 0.1s>><<if $tool.length gt 0>><<set $rndtool to $tool.pluck()>><<replace "#op">>You lost your <<= $rndtool>>. <</replace>><</if>>\
<<if $class is "human" and $cred gt 500>><<set $cred -= 500>><<append "#op">>You lost 500 credits.<</append>><</if>>\
<<if $class is "robot" and $batt gt 0>><<set $batt-->><<append "#op">>You lost 1 battery.<</append>><</if>>\
<<if $class is "freak" and $cred gt 300>><<set $cred -= 300>><<append "#op">>You lost 300 credits.<</append>><</if>>\
<<replace "#stats">><<include "Stats">><</replace>><</timed>>\
<<link "[Continue]">>\
<<goto "Start">>\
<</link>> \
<span id="op2"></span>
<span id="c_op"></span>
<span id="c_op2"></span><<set $tool to []>><<set $feat1 to "">><<set $feat2 to "">><<set $misf to "">><<set $util to "">><<set $obs to "">><<set $bag to []>><<set $storage to []>>\
<<set $xp to 0>><<set $level to 1>><<set $arena_level to 1>><<set $points to 0>>\
<<set $ship to 0>><<set $part to $tool_list.random()>>\
<<set $combat to 0>><<set $arena to 0>>\
<<set $giant to 0>><<set $rival to 0>><<set $clone to 0>><<set $enemy to 0>><<set $master to 0>>\
<<set $arm_rec to 0>><<set $darts_rec to 0>><<set $checkers_rec to 0>>\
<<set $proved to []>><<set $snstr to []>><<set $sndex to []>><<set $snwit to []>>\
<<set $favsnack to $kind.random() + " " + $food.random() + " " + $form.random()>>\
<<set $numsnacks to 0>><<set $numbeats to 0>><<set $favfound to 0>>\
<<switch $class>>\
<<case "human">>\
<<set $name to $human_name.random()+" "+$human_surname.random()>>\
<<set $classdesc to "You are the at bottom of society, the working class that lost its job for automation. Now your kind roam through the universe longing for dangerous, nasty work that no one wants to do. (2000xp/level)">>\
<<set $d1 to random(1,6)>><<set $d2 to random(1,6)>><<set $str to $d1+$d2+3>>\
<<set $d1 to random(1,6)>><<set $d2 to random(1,6)>><<set $dex to $d1+$d2+3>>\
<<set $d1 to random(1,6)>><<set $d2 to random(1,6)>><<set $wit to $d1+$d2+3>>\
<<set $hp to ($str + $dex + $wit)/ 3>><<set $hp to Math.trunc($hp)>>\
<<set $tool to $tool_list.randomMany(2)>>\
<<set $feat1 to $fashion_head.random()>>\
<<set $feat2 to $fashion_body.random()>>\
<<set $xptolvl to 2000>><<set $cred to 750>><<set $snacks to 3>><<set $batt to 5>>\
<<for _n to 0; _n lt 3; _n++>><<set $bag[_n] to $kind.random() + " " + $food.random() + " " + $form.random() >><</for>>\
<<set $proved[0] to $favsnack>><<set $snstr[0] to 3>><<set $sndex[0] to 3>><<set $snwit[0] to 3>>\
<<case "alien">>\
<<set $name to $alien_name.random()+" "+$alien_surname.random()>>\
<<set $classdesc to "This is your home planet. Everything was easy for you, until something happened and you lost everything. Now you want to regain every privilege you lost. (3000xp/level)">>\
<<set $d1 to random(1,6)>><<set $d2 to random(1,6)>><<set $d3 to random(1,6)>><<set $str to $d1+$d2+$d3>>\
<<set $d1 to random(1,6)>><<set $d2 to random(1,6)>><<set $d3 to random(1,6)>><<set $dex to $d1+$d2+$d3>>\
<<set $d1 to random(1,6)>><<set $d2 to random(1,6)>><<set $d3 to random(1,6)>><<set $wit to $d1+$d2+$d3>>\
<<set $hp to ($str + $dex + $wit)/ 3>><<set $hp to Math.trunc($hp)>>\
<<set $tool to $tool_list.randomMany(3)>>\
<<set $feat1 to $feat_head.random()>>\
<<set $feat2 to $feat_body.random()>>\
<<set $misf to $misfortune.random()>>\
<<set $xptolvl to 3000>><<set $cred to 1000>><<set $snacks to 4>><<set $batt to 6>>\
<<for _n to 0; _n lt 4; _n++>><<set $bag[_n] to $kind.random() + " " + $food.random() + " " + $form.random() >><</for>>\
<<set $proved[0] to $favsnack>><<set $snstr[0] to 4>><<set $sndex[0] to 4>><<set $snwit[0] to 4>>\
<<case "robot">>\
<<set $UniqueLabel to $robot_label.randomMany(2)>>\
<<set $name to $UniqueLabel[0]+random(1,9)+$UniqueLabel[1]+random(1,9)>>\
<<set $classdesc to "You were created to perform a routine task. Unfortunately, you could not do it perfectly, so you were thrown in the dumpster. (1000xp/level)">>\
<<set $robotabilities to [15,10,5]>>\
<<set $str to $robotabilities.pluck()>>\
<<set $dex to $robotabilities.pluck()>>\
<<set $wit to $robotabilities.pluck()>>\
<<set $hp to 10>>\
<<run $tool.push($tool_list.random())>>\
<<set $util to $utility.random()>>\
<<set $obs to $obsession.random()>>\
<<set $xptolvl to 1000>><<set $cred to 500>><<set $snacks to 2>><<set $batt to 6>>\
<<for _n to 0; _n lt 2; _n++>><<set $bag[_n] to $kind.random() + " " + $food.random() + " " + $form.random() >><</for>>\
<<case "freak">>\
<<set $name to either($human_name.random(), $alien_name.random(), $robot_label.random())>>\
<<set $surname to either($human_surname.random(), $alien_surname.random(), $robot_label.random())>>\
<<set $name to $name + " " + $surname>>\
<<set $classdesc to "You're so messed up that it's impossible to say if you are human, alien or robot. Wherever you go, no one likes you. Not even other freaks. But you love body modification and you will pursue it whatever the costs! (1500xp/level)">>\
<<set $d1 to random(1,6)>><<set $d2 to random(1,6)>><<set $str to $d1+$d2>>\
<<set $d1 to random(1,6)>><<set $d2 to random(1,6)>><<set $dex to $d1+$d2>>\
<<set $d1 to random(1,6)>><<set $d2 to random(1,6)>><<set $wit to $d1+$d2>>\
<<set $hp to ($str + $dex + $wit+10)/ 3>><<set $hp to Math.trunc($hp)>>\
<<run $tool.push($tool_list.random())>>\
<<set $feat1 to either($fashion_head.random(), $feat_head.random())>>\
<<set $feat2 to either($fashion_body.random(), $feat_body.random())>>\
<<set $xptolvl to 1500>><<set $cred to 500>><<set $snacks to 3>><<set $batt to 5>>\
<<for _n to 0; _n lt 3; _n++>><<set $bag[_n] to $kind.random() + " " + $food.random() + " " + $form.random() >><</for>>\
<<set $proved[0] to $favsnack>><<set $snstr[0] to 3>><<set $sndex[0] to 3>><<set $snwit[0] to 3>>\
<</switch>>\
Generate: \
<<link "[Human]" "Generate">><<set $class to "human">><</link>> \
<<link "[Alien]" "Generate">><<set $class to "alien">><</link>> \
<<link "[Robot]" "Generate">><<set $class to "robot">><</link>> \
<<link "[Freak]" "Generate">><<set $class to "freak">><</link>> \
<<link "[Random]" "Generate">><<set $class to either("human", "alien", "robot", "freak")>><</link>>
Name: <<= $name>>
Class: <<= $class.toUpperFirst()>>
<<= $classdesc>>
STR: <span id="str"><<= $str>></span> | \
DEX: <span id="dex"><<= $dex>></span> | \
WIT: <span id="wit"><<= $wit>></span> | \
HP: <span id="hp"><<= $hp>></span>
<<switch $class>>\
<<case "human">>\
Tools: <<= $tool.join(', ')>>
Features: <<= $feat1+" and "+$feat2>>
Favorite snack: <<= $favsnack>>
<span id="swap">\
<<link "[Swap STR and DEX]">>\
<<set $temp to $str>>\
<<set $str to $dex>>\
<<set $dex to $temp>>\
<<replace "#str">><<= $str>><</replace>>\
<<replace "#dex">><<= $dex>><</replace>>\
<<replace "#swap">><</replace>>\
<</link>> \
<<link"[Swap DEX and WIT]">>\
<<set $temp to $dex>>\
<<set $dex to $wit>>\
<<set $wit to $temp>>\
<<replace "#dex">><<= $dex>><</replace>>\
<<replace "#wit">><<= $wit>><</replace>>\
<<replace "#swap">><</replace>>\
<</link>> \
<<link "[Swap WIT and STR]">>\
<<set $temp to $wit>>\
<<set $wit to $str>>\
<<set $str to $temp>>\
<<replace "#str">><<= $str>><</replace>>\
<<replace "#wit">><<= $wit>><</replace>>\
<<replace "#swap">><</replace>>\
<</link>>\
</span>\
<<case "alien">>\
Tools: <<= $tool.join(', ')>>
Features: <<= $feat1+" and "+$feat2>>
Misfortune: <<= $misf>>
Favorite snack: <<= $favsnack>>
<<case "robot">>\
Tools: <<= $tool.join(', ')>>
Function: <<= $util>>
Obsession: <<= $obs>>
Favorite snack: <<= $favsnack>>
<span id="swap">\
<<link "[Swap STR and DEX]">>\
<<set $temp to $str>>\
<<set $str to $dex>>\
<<set $dex to $temp>>\
<<replace "#str">><<= $str>><</replace>>\
<<replace "#dex">><<= $dex>><</replace>>\
<</link>> \
<<link"[Swap DEX and WIT]">>\
<<set $temp to $dex>>\
<<set $dex to $wit>>\
<<set $wit to $temp>>\
<<replace "#dex">><<= $dex>><</replace>>\
<<replace "#wit">><<= $wit>><</replace>>\
<</link>> \
<<link "[Swap WIT and STR]">>\
<<set $temp to $wit>>\
<<set $wit to $str>>\
<<set $str to $temp>>\
<<replace "#str">><<= $str>><</replace>>\
<<replace "#wit">><<= $wit>><</replace>>\
<</link>>\
</span>\
<<case "freak">>\
Tools: <<= $tool.join(', ')>>
Features: <<= $feat1+" and "+$feat2>>
Favorite snack: <<= $favsnack>>
<<set $points to 10>>\
<span id="stats">
<span id="points">Points: <<= $points>></span>
<<link "[Raise STR]">>\
<<set $points-->>\
<<set $str++>>\
<<replace "#str">><<= $str>><</replace>>\
<<replace "#points">>Points: <<= $points>><</replace>>\
<<if $points is 0>><<replace "#stats">><</replace>><</if>>\
<</link>> \
<<link"[Raise DEX]">>\
<<set $points-->>\
<<set $dex++>>\
<<replace "#dex">><<= $dex>><</replace>>\
<<replace "#points">>Points: <<= $points>><</replace>>\
<<if $points is 0>><<replace "#stats">><</replace>><</if>>\
<</link>> \
<<link "[Raise WIT]">>\
<<set $points-->>\
<<set $wit++>>\
<<replace "#wit">><<= $wit>><</replace>>\
<<replace "#points">>Points: <<= $points>><</replace>>\
<<if $points is 0>><<replace "#stats">><</replace>><</if>>\
<</link>>\
</span>\
<</switch>>
<<link "[Help]">>\
<<dialog 'Help'>>\
STR: Strength. Affects dealing and resisting damage.
DEX: Dexterity. Affects combat initiative, running from combat and stealing.
WIT: Wit. Affects perception, avoiding ambushes and other tests.
HP: Hit Points. How much damage you can take before dropping.
XP: Experience Points. The measure of your character progress.
<</dialog>>\
<</link>> \
<<link "[Start]" "Start">><<set $maxhp to $hp>><<set $loc to $planet.random()>><<set $next to ($xptolvl*$level)>>\
<<set $ostr to $str>><<set $odex to $dex>><<set $owit to $wit>>\
<</link>> \<img id="imgElem">
<<script>>
$(document).one(':passagerender', function (ev) {
var img = $(ev.content).find('#imgElem');
var baseStr64 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gINCBMCngDqkgAABF1JREFUOMuFlFtsVFUUhr99zplz6ZyZztChLVCgTSPElJoW0aQBSVBAIyGi9sUXiEXB8AARo+iDEjFGHwRjfNA0BhIxRoxGfSCxpIEUCVabcgmoyK1CS1uY6XWu57p96CCiif7JylpZ2etfa+/1Z8N/YU/4r5S8hSnTsUfK8f9jsn4FPJe+O/me00BnthFApuMH5HiblCPMA5ALWpGbUn8dFQAD89cRV4tJTbiLKgdO/BR78lyiEK/qCGYlO4ibTSRcSJaoTI4yueIxUFtB3syxb+AzroztEZ87I7cJFYCGwcMUZGRzUVEP8nB/m+Y744FU9y7T+5reir8OQgcBLfY5IAoyAJm0ebHlBZabX8iXEfL7GULtZt1qaoa6mUZsmKsV77kqt5104gFT1RHun9NH/eRlsH3wBNJRQY6BbCw/qALtD6zkxpmVYmmmR17X0GqGugGoUyab4maOREUe7CwkpunPtXLLSaHqkqAQoX94GYQjQB6IQCgBFWoXd0HGFAv8mSsPzln3ran4CTQJWgCREIyQpYVLXLRW0FXdjpGH/EQdm4/ug/AEBEAYlM0w5GDbDgDlbOXGeQixWggJaghq2QvA9DHdIt8NrcTJKZAP2X9hB50/t0PpGHgF8DzwXHBFu7zSJrRQarORQp/Z9992r4RkqnRaj3/KqNUA0QIYEVAVth7ppCl/nuX3/QjqEsCCwGsW956Smh9q1UGoRGQoIFCQvsLYUIKvL63iVGwxTDnE3FEcx8bXTaSmIEON3b0ddKe2Q/I8aIshEJXyQM3bWsk3q7xQl4HUBJ5CadokrgfgKpy43kzMThNxHBwjhx/RCRUVIRRuTMVmRDcRgnENRC2oEVOTofKr4xuBF0Y0y1WwPCDusrXlMKlMhpNjzdQ3ZIilShw68ygXby1EotJYex4sIA34BZBZqA5Oa05gjJf8ilLJt+xokEV1BQiBO1bDE/PO8lRLLyRCplSDXNonfWEDuZJg17PfQBbwyyamQcqvtDXBu4M97s5Mzo3Ztj5FRdGDnIduBXx4+HEmA50JEdI/vBApTCyRpn3tcR5adBVuAS4zEhJONx6OAoKSa70yVUySd2P4TgSmDMhKti05ii9dRjJJaiNZ5lsjbF//Ja8+3QWjZX0XgbyAP2KHxEakkJ0gtsAPxo4jtfHhNTXRYWwji0gWYXYRavI4UXAqAqKpHKpd1uhtuAL5ewIxt1gvXitdEwDd2i6CUKlLmBOna2LDqVTFTSqMAiLhwKwSJEsQdyHmQYUPRgBKCL4KRQ10/3nxhveJfP/uXvToOxO2MX1qdnS0ocrKYOkFhO1CpQtxB6I+mAHoZcKSOkAkXC8+nvxF7jYQbzp3CI9FXmKVt5eDfKQ2x3s/SFiTmxLWuF2h5dEMF2GVpzMDsqFGOjenu7H3+FoQUnbMQuwfv/PB/hN90S3kgpioj19+xjZymy2t8KChlWxVCdJC93tCI3znt6rY6SVdffKftX8CBMXrIvMsmx4AAAAASUVORK5CYII=";
img.attr('src', baseStr64);
})
<</script>>